Created
November 19, 2019 23:46
-
-
Save j05h/a19911e2a78835d2794dd3b5d2ac9a6d to your computer and use it in GitHub Desktop.
Git Stats that developers committed between two dates
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 | |
# Super lame because I'm not even using optparse. Killme. | |
# gitstats.rb from-date to-date | |
# Will find the commit stats for all developers on a project within those dates. | |
# Example: | |
# gitstats.rb 2019-03-22 2019-04-01 | |
# gets all stats betwee the above dates exclusive. | |
from = ARGV.shift | |
to = ARGV.shift | |
from ||= (Time.now - (7 * 24 * 3600)).strftime('%Y-%m-%d') | |
to ||= Time.now.strftime('%Y-%m-%d') | |
authors = `git shortlog -se --all --since #{from} --before #{to} | awk '{print $(NF)}'`.split("\n").sort.uniq | |
puts "Git Stats from #{from} to #{to}\n\n" | |
authors.each do |name| | |
name = name.delete('<').delete('>') | |
puts name | |
puts ' ' + `git log --shortstat --all --no-merges --author "#{name}" --since #{from} --before #{to} | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'` | |
end | |
puts 'Total' | |
puts ' ' + `git log --shortstat --all --no-merges --since #{from} --before #{to} | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment