Skip to content

Instantly share code, notes, and snippets.

@kiselev-nikolay
Last active August 5, 2021 09:05
Show Gist options
  • Save kiselev-nikolay/0c472eed37c85eeabe227f47fe3af5ac to your computer and use it in GitHub Desktop.
Save kiselev-nikolay/0c472eed37c85eeabe227f47fe3af5ac to your computer and use it in GitHub Desktop.
Get git stat by lines
#!/usr/bin/fish
function git_stat
for i in (git log --format='%aN' | sort -u)
printf "STAT %s%s%s\n" (set_color red) "$i" (set_color normal)
git log --author="$i" --pretty=tformat: --numstat | awk '{inserted+=$1; deleted+=$2; delta+=$1-$2; ratio=deleted/inserted} END {printf "STAT Commit stats:\nSTAT - Lines added (total).... %s\nSTAT - Lines deleted (total).. %s\nSTAT - Total lines (delta).... %s\nSTAT - Add./Del. ratio (1:n).. 1 : %s\n", inserted, deleted, delta, ratio }' -
echo
end
end
git_stat 2>&1 | grep "STAT" | less -R
@kiselev-nikolay
Copy link
Author

Example:

Name goes there
Commit stats:
- Lines added (total)....  7082
- Lines deleted (total)..  2938
- Total lines (delta)....  4144
- Add./Del. ratio (1:n)..  1 : 0.414855

@kiselev-nikolay
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment