Skip to content

Instantly share code, notes, and snippets.

@rcoup
Created September 20, 2023 10:09
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 rcoup/3dedc99b90794a0a4950dd1c3e499b8b to your computer and use it in GitHub Desktop.
Save rcoup/3dedc99b90794a0a4950dd1c3e499b8b to your computer and use it in GitHub Desktop.
Simple bash script to run cloc across a big pile of repositories
#!/bin/bash
set -euo pipefail
# simple repo cloc report
# * ignores submodules
GIT_REMOTE="git@github.com:myorg"
REPOS=(
myfirstrepo
mysecondrepo
)
# see `man clock` for options:
# CLOC_OPTIONS=--exclude-dir=vendor
for REPO in "${REPOS[@]}"; do
echo "Processing $REPO ..."
if ! [ -d "$REPO" ]; then
git clone --depth 1 --single-branch "${GIT_REMOTE}/${REPO}.git" "$REPO"
fi
REPO_CLOC_REPORT="${REPO}.cloc-report"
if ! [ -f "$REPO_CLOC_REPORT" ]; then
cloc --report-file "$REPO_CLOC_REPORT" "$REPO" ${CLOC_OPTIONS-}
fi
done
cloc --sum-reports ./*.cloc-report
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment