Created
October 28, 2024 21:50
-
-
Save andrew8088/5756abcdc1f1a0f3b52e0555cd32f5eb to your computer and use it in GitHub Desktop.
This file contains 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 | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <subdirectory>" | |
exit 1 | |
fi | |
SUBDIR="$1" | |
GIT_ROOT=$(git rev-parse --show-toplevel) | |
if [ $? -ne 0 ]; then | |
echo "Error: The specified directory is not within a Git repository." | |
exit 1 | |
fi | |
count_loc() { | |
find "$SUBDIR" -type f -print0 | xargs -0 wc -l | tail -n 1 | awk '{print $1}' | |
} | |
cd "$GIT_ROOT" || exit | |
commits=$(git rev-list --reverse HEAD) | |
i=0 | |
for commit in $commits; do | |
if (( i % 500 == 0 )); then | |
git clean -fdq | |
git checkout -q "$commit" | |
hash=$(git log -1 --format="%H") | |
date=$(git log -1 --format="%ad" --date=short) | |
loc=$(count_loc) | |
echo "$date, $loc" | |
fi | |
((i++)) | |
done | |
git checkout -q master | |
git clean -fdq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment