Skip to content

Instantly share code, notes, and snippets.

@metalelf0
Created October 18, 2012 12:54
Show Gist options
  • Save metalelf0/3911620 to your computer and use it in GitHub Desktop.
Save metalelf0/3911620 to your computer and use it in GitHub Desktop.
Git commit daily logger - A ruby script to show your commits on multiple projects, grouped by date
require 'rubygems'
require 'git'
require 'rainbow'
PROJECT_PATHS = %w(
/path/to/your/project
/path/to/another/project
)
EMAIL_ADDRESSES = %w( [email protected] )
class GitCommit
attr_accessor :email, :date, :commit_message, :project
def initialize args={}
args.each_pair { |key, val| self.send(key.to_s + "=", val) }
end
def to_s
"#{project.split("/").last}".color(:yellow) + " #{date.strftime('%Y-%m-%d %H:%M')}: #{email} - #{commit_message}"
end
end
commits = []
PROJECT_PATHS.each do |project_path|
git_repo = Git.open(project_path)
git_repo.log.each do |log_entry|
if EMAIL_ADDRESSES.include?(log_entry.author.email)
git_commit = GitCommit.new(:email => log_entry.author.email, :date => log_entry.date, :commit_message => log_entry.message, :project => project_path)
commits << git_commit
end
end
end
commits.group_by {|c| c.date.strftime("%Y-%m-%d") }.sort {|c1, c2| c2.first <=> c1.first }.each do |date, commits|
puts date.color(:blue)
puts "==========".color(:blue)
commits.sort { |c1, c2| c2.date <=> c1.date }.each do |commit|
puts commit
end
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment