Created
December 29, 2018 23:29
-
-
Save brwyatt/f1ff78257de8494be56d50c3a7c6259e to your computer and use it in GitHub Desktop.
Script to count the lines of Puppet code for each commit in a Git repo
This file contains hidden or 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
#!/bin/bash | |
file="/tmp/count.csv" | |
echo "datetime,commit,lines" > "${file}" | |
for i in $(git log --pretty='%ct:%H'); do | |
d=$(echo "${i}"|cut -f1 -d':') | |
c=$(echo "${i}"|cut -f2 -d':') | |
echo "Processing ${c} @ ${d}" | |
git checkout "${c}" > /dev/null 2>&1 | |
git clean -dfx > /dev/null 2>&1 | |
l=$(find ./ -type f -name '*.pp' | xargs grep -Ev '^\s*(#.*)?$' | wc -l) | |
echo "${d},${c},${l}" >> "${file}" | |
done | |
# vim: ts=4 sts=4 sw=4 expandtab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment