Skip to content

Instantly share code, notes, and snippets.

@jdforsythe
Last active October 18, 2021 21:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdforsythe/cf52d76e3092825e1033dbae44af8ade to your computer and use it in GitHub Desktop.
Save jdforsythe/cf52d76e3092825e1033dbae44af8ade to your computer and use it in GitHub Desktop.
Show stats in git repo
#!/bin/bash
# did you pass all the arguments?
nl=$'\n'
if [ $# -lt 3 ]; then
echo 1>&2 "$0: not enough arguments${nl}USAGE: changes-between-commits.sh \"Author Name\" FROM_COMMIT_SHA TO_COMMIT_SHA"
exit 2
elif [ $# -gt 3 ]; then
echo 1>&2 "$0: too many arguments${nl}USAGE: changes-between-commits.sh \"Author Name\" FROM_COMMIT_SHA TO_COMMIT_SHA"
exit 2
fi
echo "${nl}Stats for ${1} from $2..$3${nl}"
git log --numstat --pretty="%H" --author="$1" $2..$3 | awk 'NF==3 {count+=1; insertions+=$1; deletions+=$2} END {printf("%d file(s) changed, %d insertions(+), %d deletions(-), %d net", count, insertions, deletions, (insertions-deletions))}'
#!/bin/bash
# did you pass all the arguments?
nl=$'\n'
if [ $# -lt 2 ]; then
echo 1>&2 "$0: not enough arguments${nl}USAGE: changes-since.sh \"Author Name\" \"2016-07-17\""
exit 2
elif [ $# -gt 2 ]; then
echo 1>&2 "$0: too many arguments${nl}USAGE: changes-since.sh \"Author Name\" \"2016-07-17\""
exit 2
fi
echo "${nl}Stats for ${1} since $2${nl}"
git log --numstat --pretty="%H" --author="$1" --since="$2" | awk 'NF==3 {count+=1; insertions+=$1; deletions+=$2} END {printf("%d file(s) changed, %d insertions(+), %d deletions(-), %d net", count, insertions, deletions, (insertions-deletions))}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment