Created
November 3, 2015 22:43
-
-
Save andrew-carroll/35746a21043812091cab to your computer and use it in GitHub Desktop.
This file contains 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 | |
pwd = `pwd`.strip | |
targets = if ARGV.empty? | |
Dir["#{pwd}/*"] | |
else | |
ARGV.map do |arg| | |
Dir["#{arg.strip.gsub(/\/*$/,'')}/*"] | |
end.flatten.uniq | |
end | |
targets.each do |target| | |
target.gsub!(/#{pwd}/, '.') | |
last_commit = `git log -- #{target}` | |
longest_line_length = last_commit.lines.map(&:length).max || 60 | |
max_length = longest_line_length > 60 ? longest_line_length : 60 | |
header = [ | |
".#{'-' * (max_length - 2)}.", | |
"| #{target.ljust(max_length - 3)}|", | |
"|#{'-' * (max_length - 2)}|" | |
] | |
footer = ["`#{'-' * (max_length - 2)}x"].join("\n") | |
formatted = last_commit.lines.map do |line| | |
"| #{line.strip.ljust(max_length - 4)} |" | |
end | |
puts header, formatted, footer | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment