Skip to content

Instantly share code, notes, and snippets.

@andynu
Created August 21, 2025 18:43
Show Gist options
  • Save andynu/2d484817bae43ef5aaac5a914fe3c6d4 to your computer and use it in GitHub Desktop.
Save andynu/2d484817bae43ef5aaac5a914fe3c6d4 to your computer and use it in GitHub Desktop.
git-log-all me last wekk - shows me what I did last week across all the git folders under cwd.
#!/usr/bin/env ruby
# # Git Log All
#
# A comprehensive git log analysis tool that generates detailed commit reports
# with time-based filtering and author-specific views. Perfect for reviewing
# development activity across different time periods.
#
# ## Features
# - Time-based commit analysis (day, week, month, year)
# - Author-specific filtering (me/andy, scott/skm)
# - Color-coded output with visual formatting
# - Detailed commit information including messages and file changes
# - Date range reporting with automatic boundary calculation
# - Support for historical analysis (last/one/two/three periods ago)
#
# ## Usage
# ```bash
# git-log-all # Current week, all authors
# git-log-all me week # My commits this week
# git-log-all me month # Scott's commits this month
# git-log-all day last # All commits from yesterday
# git-log-all me year two # My commits from 2 years ago
# ```
#
# ## Time Scopes
# - `day`: Single day analysis
# - `week`: Weekly analysis (default)
# - `month`: Monthly analysis
# - `year`: Yearly analysis
#
# ## Author Filters
# - `me/mine/andy`: Filter to andy's commits
# - (no filter): Show all authors
#
# ## Offset Options
# - `last/one`: Previous period
# - `two`: Two periods ago
# - `three`: Three periods ago
require 'active_support/all'
require 'chronic'
require 'rainbow'
me = ARGV.any?{|arg| arg.downcase.in? %w[my mine andy me --me] }
skm = ARGV.any?{|arg| arg.downcase.in? %w[scott skm --skm --scott] }
scope = ARGV.select{|arg| arg.in? %w[day week month year] }.first || 'week'
offset = ARGV.select{|arg| arg.in? %w[last one two three] }
offset = {
'this' => 0,
'last' => 1,
'one' => 1,
'two' => 2,
'three' => 3,
}
start_time = Time.now.send("beginning_of_#{scope}")
start_time -= 1.send(scope) if offset
end_time = start_time
end_time = end_time.send("end_of_#{scope}")
puts "#{scope}: #{start_time.to_date} to #{end_time.to_date}"
time_range = []
t = start_time
until t > end_time
time_range << t.to_date.to_s
t += 1.day
end
Dir['*'].each do |dir|
shown_proj = false
cmd = "cd #{dir} 2>/dev/null; git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short --decorate=full 2>/dev/null"
status = `#{cmd}`
status.each_line do |line|
if me && !(line =~ /(andy)/)
next
end
line =~ /(\d{4}-\d{2}-\d{2})/
line_date = $1
if line_date.in? time_range
if !shown_proj
puts
puts Rainbow(dir).green
shown_proj = true
end
puts line.indent(4)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment