Skip to content

Instantly share code, notes, and snippets.

@thearchduke
Created May 28, 2020 19:08
Show Gist options
  • Save thearchduke/dca2924cfa34ae605ee09e426756447d to your computer and use it in GitHub Desktop.
Save thearchduke/dca2924cfa34ae605ee09e426756447d to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# please use 2.4.0+
# Recursively searches your directory of repos to find the specified regex in commit messages,
# and produces a histogram by author.
# e.g. "./commitsearch.rb 'fu*ck'"
authors = []
Dir.glob('*').select { |f| File.directory? f } .sort .each do |d|
Dir.chdir(d) do
`git checkout master --quiet`
raw_authors = `git log -i --grep='#{ARGV[0]}' | grep Author`
next unless raw_authors.length > 1
authors += raw_authors.split("\n")
end
end
histogram = authors.group_by(&:itself).transform_values(&:size).sort_by {|_, v| -v}
puts histogram.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment