Skip to content

Instantly share code, notes, and snippets.

@tompng
Created June 15, 2024 15:53
Show Gist options
  • Save tompng/d718b0fb576c99b250e27a4ef1184bce to your computer and use it in GitHub Desktop.
Save tompng/d718b0fb576c99b250e27a4ef1184bce to your computer and use it in GitHub Desktop.
git log additions and deletions
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