class GitFindCommitter::Committer
Public Class Methods
new(repo, branch, config)
click to toggle source
# File lib/git_find_committer/committer.rb, line 3 def initialize(repo, branch, config) @config = config @config.set_repo(repo) @config.branch = branch end
Public Instance Methods
diff_files()
click to toggle source
# File lib/git_find_committer/committer.rb, line 9 def diff_files `cd #{@config.tmp_repo_path} && git diff --name-only origin/#{@config.branch} origin/master`.split("\n").map { |val| val.chomp } end
find(file)
click to toggle source
# File lib/git_find_committer/committer.rb, line 28 def find(file) {"#{file}" => `cd #{@config.tmp_repo_path} && git log --follow --pretty=format:"%an" #{file} 2>/dev/null` }.each_with_object(Hash.new(0)) do |(file, committer), k| committer.split("\n").each {|r| k[r]+=1 } end.sort {|(k1, v1), (k2, v2)| v2 <=> v1 }.to_h end
search()
click to toggle source
# File lib/git_find_committer/committer.rb, line 13 def search Repository.new(@config).prepare_repo.pull_master result = diff_files.each_with_object(Hash.new(0)) do |file, k| find(file).each do |committer, commit_count| k[committer] += commit_count end end.sort { |(k1, v1), (k2, v2)| v2 <=> v1 }.to_h result = result.each_with_object([]) do |(key,val),arr| arr << {name: key, commit_count: val} end Response.new(Filter.new(@config).select_committer(result)) end