Skip to content

Instantly share code, notes, and snippets.

@jgdavey
Created January 26, 2012 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgdavey/1685824 to your computer and use it in GitHub Desktop.
Save jgdavey/1685824 to your computer and use it in GitHub Desktop.
Harvest your git messages
#!/usr/bin/env ruby
# Adapted from https://gist.github.com/946311
#
# To use, put something like the following in your .bashrc.local:
#
# alias harvest='rvm use 1.9.2@harvester;harvester;cd ..;cd -'
author = `git config --global user.name`.chomp
require 'rubygems'
require 'active_support/all'
require 'grit'
include Grit
repo = Repo.new(".")
only_commits_with = ARGV[0] || "#"
puts "Commits for #{author} from last 8 days containing '#{only_commits_with}'\n\n"
commits = repo.commits_since('HEAD', 8.days.ago).select{|c| c.author.name.include?(author)}.select{|c| c.message.include?(only_commits_with) }
commits_by_date = commits.group_by {|x| x.authored_date.to_date}
output = commits_by_date.map { |date, commits|
# Only first line of each message
messages = commits.map { |c| c.message.split("\n")[0] }.join("; ")
[date, messages].join("\n")
}.join("\n\n")
puts output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment