Skip to content

Instantly share code, notes, and snippets.

@joaoantoniocardoso
Last active December 1, 2019 03:39
Show Gist options
  • Save joaoantoniocardoso/d5067703e3c51f1f1c88c5362fd64b52 to your computer and use it in GitHub Desktop.
Save joaoantoniocardoso/d5067703e3c51f1f1c88c5362fd64b52 to your computer and use it in GitHub Desktop.
#!/bin/sh
# requires: cloc (https://github.com/AlDanial/cloc)
# Clone all repos:
REPOS=(BOAT19 MT19 MRPC19 MAB19 MCB19 MCS19 MCT19 MFP19 MIC19 MSC19 MVC19 MSWI19 MAM19 FUPCI19)
BASE_URL=https://github.com/ZeniteSolar/
for repo in ${REPOS[*]}; do
git clone $BASE_URL/$repo
done
# Count line of code of all unique files over all repos:
cloc --quiet --timeout 0 *
# Find and merge all .c and .h files:
cat >> merged.c $(find . -name '*.c')
cat >> merged.h $(find . -name '*.h')
# Sort duplicated and unique lines to separated files:
sort merged.c | uniq -d >> duplicated.c
sort merged.h | uniq -d >> duplicated.h
sort merged.c | uniq -u >> unique.c
sort merged.h | uniq -u >> unique.h
# Count all lines of code (over non-unique files), duplicated and unique lines:
cloc --by-file --quiet --timeout 0 merged.* duplicated.* unique.*
# Clean
rm merged.c merged.h duplicated.c duplicated.h unique.c unique.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment