Created
January 26, 2012 23:28
-
-
Save jgdavey/1685824 to your computer and use it in GitHub Desktop.
Harvest your git messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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