Created
July 14, 2020 13:00
-
-
Save lcguida/cb30f4e8b98bb3358d44c3d5a2f1fe6d to your computer and use it in GitHub Desktop.
Search my commits given a period
This file contains hidden or 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 | |
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