Skip to content

Instantly share code, notes, and snippets.

@AndrewRadev
Created May 13, 2013 09:32
Show Gist options
  • Save AndrewRadev/5567179 to your computer and use it in GitHub Desktop.
Save AndrewRadev/5567179 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
require 'date'
require 'fileutils'
def output_log
# TODO (2013-05-13) Branch info would be nice
log_format = '%Cred%h%Creset -%Creset %s %Cgreen(%cD) %C(bold blue)<%an>%Creset'
author = %x[git config user.email].strip
today = Time.now.to_date
week_day = Date::DAYNAMES[today.wday]
if week_day == 'Monday'
last_working_day = today - 3
else
last_working_day = today - 1
end
%x<git log --pretty=format:"#{log_format}" --since="#{last_working_day.to_s}" --author="#{author}">
end
if File.directory?('.git')
puts output_log
end
Dir['*/.git'].each do |git_dir|
project_dir = File.dirname(git_dir)
project_log = nil
FileUtils.cd(project_dir) do
project_log = output_log.strip
end
if project_log != ''
header = ">> Project: #{project_dir}"
puts "=" * header.size
puts header
puts "=" * header.size
puts project_log
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment