class RepoCompare::GitDiffRaw
Compare 2 repos
Constants
- DIFF_OPTIONS
- EXP
Public Class Methods
new(config, path)
click to toggle source
# File lib/repo-compare/git_diff_raw.rb, line 9 def initialize(config, path) @config = config @context = { output: [] } @path = path end
Public Instance Methods
call()
click to toggle source
# File lib/repo-compare/git_diff_raw.rb, line 15 def call compare_repos filter_changes extract_results @context.merge!(success?: true) end
Private Instance Methods
compare_repos()
click to toggle source
# File lib/repo-compare/git_diff_raw.rb, line 24 def compare_repos cmd = "git diff #{DIFF_OPTIONS} 'remotes/#{@config['source_name']}/#{@config['source_branch']}' -- " cmd += "'#{@config['source_base_path']}/#{@path}' '#{@path}'" @context[:output] = `#{cmd}`.scan(EXP) @context end
extract_results()
click to toggle source
# File lib/repo-compare/git_diff_raw.rb, line 31 def extract_results @context[:output].sort_by! { |item| item[3] } @context[:results] = {} @context[:output].each_with_object(@context[:results]) do |item, ret| ret[item[3]] = item[0] end @context end
filter_changes()
click to toggle source
# File lib/repo-compare/git_diff_raw.rb, line 40 def filter_changes ignore = @config['ignore'][@path] || [] @context[:output].reject! { |line| line[0] == line[1] || ignore_changes?(ignore, line) } @context end
ignore_changes?(ignore, line)
click to toggle source
# File lib/repo-compare/git_diff_raw.rb, line 46 def ignore_changes?(ignore, line) path = line[3] ignore[path] == '-' || ignore[path] == line[0] end