Skip to content

Instantly share code, notes, and snippets.

@nfelger
Created March 22, 2013 14:14
Show Gist options
  • Save nfelger/5221574 to your computer and use it in GitHub Desktop.
Save nfelger/5221574 to your computer and use it in GitHub Desktop.
get commit messages
require 'grit'
root_dir = "/some/path"
terms = ['niko', 'nfelger']
Dir[root_dir + "/*/.git"].each do |dir|
repo = Grit::Repo.new(dir)
File.open("/where/ever/commit_messages/#{dir.split('/')[-2]}", 'w') do |file|
step = 100
offset = -step
while (commits = repo.commits('master', step, offset += step)).any?
commits.each do |commit|
if terms.any?{|term| commit.author_string =~ /#{term}/i}
file.puts commit.message
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment