Skip to content

Instantly share code, notes, and snippets.

@bhcleek
Created April 19, 2016 04:08
Show Gist options
  • Save bhcleek/3ff8b905701139d336ce431298940b2f to your computer and use it in GitHub Desktop.
Save bhcleek/3ff8b905701139d336ce431298940b2f to your computer and use it in GitHub Desktop.
cloc-per-tag
#!/bin/sh
ROOT="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd "${ROOT}"
fmt='
r=%(refname)
d=%(taggerdate:format:%F)
monday=$(date -j -f "%Y-%m-%d" -v+mon $d "+%Y-%m-%d")
git checkout %(refname)
echo $(basename %(refname)) - $monday:
cloc --exclude-dir=.git --json --quiet .
'
eval=`git for-each-ref --shell --format="$fmt" \
--sort=-taggerdate \
refs/tags`
eval "$eval"
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment