Last active
August 29, 2015 14:03
-
-
Save jaytaylor/f806187d4629296b5c76 to your computer and use it in GitHub Desktop.
Git repository statistics: Get # of commits and lines changed since some previous point in time
This file contains 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 bash | |
set -e | |
## | |
# @author Jay Taylor [@jtaylor] | |
# | |
# @date 2014-06-28 | |
# | |
# @description Git repository statistics: Get # of commits and lines changed since some previous point in time. | |
# | |
test -z "$*" && echo 'error: missing required `git log` filter expression, e.g. "Apr 2[8-9] .* 2014"' 1>&2 && exit 1 | |
startDate="$*" | |
commit="$(git log | grep -B 2 " ${startDate}" | tail -n3 | head -n1 | cut -d' ' -f2)" | |
test -z "${commit}" && echo "error: date ${startDate} not found" 1>&2 && exit 1 | |
#echo "commit=${commit}" | |
commitCount="$(git log "${commit}..HEAD" | grep '^commit ' | wc -l | sed 's/^ \{1,\}//')" | |
stats="$(git diff --shortstat "${commit}..HEAD" | sed 's/^ \{1,\}//')" | |
echo "${commitCount} commits, ${stats}" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment