Skip to content

Instantly share code, notes, and snippets.

@lcguida
Created July 14, 2020 13:00
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 lcguida/cb30f4e8b98bb3358d44c3d5a2f1fe6d to your computer and use it in GitHub Desktop.
Save lcguida/cb30f4e8b98bb3358d44c3d5a2f1fe6d to your computer and use it in GitHub Desktop.
Search my commits given a period
#!/usr/bin/env ruby
require 'date'
def print_usage
puts "USAGE: gsearch <from> [<to>]"
exit 1
end
print_usage if ARGV.size < 1 || ARGV.size > 2
begin
from = Date.strptime(ARGV[0],"%d/%m/%Y")
if ARGV[1]
to = Date.strptime(ARGV[1],"%d/%m/%Y")
end
rescue ArgumentError
puts 'Invalid date format. Valid format: dd/mm/YYYY'
print_usage
end
str_from = from.strftime("%Y-%m-%d")
to = to || from + 1
str_to = to.strftime("%Y-%m-%d")
puts "Showing commits from #{str_from} to #{str_to}"
git_command = 'git log --all --date=iso-local --pretty=format:\'%ad %aN %s\' --author="Leandro Guida" --reverse'
command = "#{git_command} | awk '$0 >= \"#{str_from}\" && $0 <= \"#{str_to}\"'"
system(command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment