Created
September 20, 2023 10:09
-
-
Save rcoup/3dedc99b90794a0a4950dd1c3e499b8b to your computer and use it in GitHub Desktop.
Simple bash script to run cloc across a big pile of repositories
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 | |
set -euo pipefail | |
# simple repo cloc report | |
# * ignores submodules | |
GIT_REMOTE="[email protected]: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