Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
count LOC in .git folders per language
#!/bin/bash
set -e -u -o pipefail # -x
echo $'Project\tCommit\tBranch\tFiletype\tLines'
for dir in *.git; do
export GIT_DIR="$dir"
export PREFIX=$(git for-each-ref --count=1 --sort=committerdate --format=$'%(objectname)\t%(refname)')
export BRANCH=$(echo -e "${PREFIX}" | cut -d $'\t' -f 1)
##### from these filetypes #####
for filetype in java cs rb go py as php html htm css js json xml conf cnf; do
echo -n -e "${dir}\t${PREFIX}\t${filetype}\t"
git --no-pager grep -h "" "${BRANCH}" -- "*.${filetype}" | wc -l || true
done
done | egrep -v $'\t0$'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment