Created
June 15, 2024 15:53
-
-
Save tompng/d718b0fb576c99b250e27a4ef1184bce to your computer and use it in GitHub Desktop.
git log additions and deletions
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
username = '...' | |
commits = `git log | grep -n1 "#{username}"`.scan(/-commit ([0-9a-f]+)/).flatten | |
result = commits.map do |commit| | |
stat = `git show #{commit} --stat -- lib` | |
diff = stat[/(\d+) insertion/].to_i - stat[/(\d+) deletion/].to_i | |
[commit, diff] | |
end | |
add_deletes = commits.map do |commit| | |
stat = `git show #{commit} -- lib` | |
add = stat.scan(/^\+([^+]|$)/).size | |
del = stat.scan(/^\-([^-]|$)/).size | |
[commit, add, del] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment