Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaytaylor/f806187d4629296b5c76 to your computer and use it in GitHub Desktop.
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
#!/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