Skip to content

Instantly share code, notes, and snippets.

@zph
Created June 23, 2014 18:45
Show Gist options
  • Select an option

  • Save zph/e8b3d7bd4a0a756cdaf3 to your computer and use it in GitHub Desktop.

Select an option

Save zph/e8b3d7bd4a0a756cdaf3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# Usage: ./git-all-commits ~/source > commits.log
# commits.log will contain all commits in following format:
# repo_name: SHA FIRSTLINE_COMMIT_MSG
require 'pathname'
dir = ARGV.dup.first
# INITIALS = 'zh' # replace with your own
INITIALS = nil # Place initials here
unless INITIALS
warn "Must place INITIALS on Line 7."
exit(1)
end
dirs = Dir.glob("#{File.expand_path(dir)}/*")
output = dirs.flat_map do |d|
if Dir.exists?(d) && Dir.exists?(File.join(d, ".git"))
Dir.chdir(d) do
log = `git log --oneline`.chomp.split("\n")
log.map { |l| [d, l].join(": ")}
end
end
end.compact
output.select! { |i| i[/#{INITIALS}/i] }
output.reject! { |i| i.split(" ")[2][/^Merge/]}
puts output.join("\n")
@zph

zph commented Jun 23, 2014

Copy link
Copy Markdown
Author

Replace INITIALS with your own, then run like ./git-all-commits ~/source > commits.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment