fix: consolidation and using git to grab commit count

This commit is contained in:
gitea-analytics-bot
2026-01-21 21:56:47 -05:00
parent c254bbf08a
commit 82fb2fc961

View File

@@ -19,55 +19,27 @@ jobs:
git fetch origin
git rebase origin/${{ github.ref_name }}
- name: Fetch Commit Velocity
- name: Process Statistics and Update README
run: |
SINCE_DATE="2026-01-01T00:00:00Z"
PAGE=1
TOTAL_NAMES=0
HUMAN_COUNT=$(git rev-list --count --author="patrick" --since="2026-01-01" --all)
while true; do
echo "Requesting Page $PAGE..."
URL="http://gitea-http:3000/api/v1/repos/${{ github.repository }}/commits?since=${SINCE_DATE}&page=${PAGE}&limit=50"
echo "Local Git detected $HUMAN_COUNT commits by Patrick since Jan 1."
RESP=$(wget -qO- --header="Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$URL")
if [ "$RESP" = "[]" ] || [ -z "$RESP" ]; then
echo "Reached the end of history at page $PAGE."
break
fi
PAGE_NAMES=$(echo "$RESP" | grep -o "\"name\":\"patrick\"" | wc -l || echo 0)
echo "Page $PAGE: Found $PAGE_NAMES name matches."
TOTAL_NAMES=$((TOTAL_NAMES + PAGE_NAMES))
PAGE=$((PAGE + 1))
if [ "$PAGE" -gt 100 ]; then break; fi
done
RAW_COUNT=$((TOTAL_NAMES / 2))
echo "COMMIT_VELOCITY=$RAW_COUNT" >> $GITHUB_ENV
echo "Final tally for Patrick: $RAW_COUNT"
- name: Update README
env:
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
run: |
LOC=$(grep '"total_code"' public/code-stats.json | sed 's/[^0-9]*//g')
FORMATTED_LOC=$(printf "%'d" $LOC)
echo "Injecting $FORMATTED_LOC & $COMMIT_VELOCITY into README.template..."
echo "Injecting $FORMATTED_LOC LOC and $HUMAN_COUNT Commits into README..."
sed "s/REPLACE_ME_LOC/$FORMATTED_LOC/g" README.template | \
sed "s/REPLACE_ME_COMMITS/$COMMIT_VELOCITY/g" > README.md
sed "s/REPLACE_ME_COMMITS/$HUMAN_COUNT/g" > README.md
if [ ! -s README.md ]; then
echo "Error: README.md is empty!"
exit 1
fi
echo "FORMATTED_LOC=$FORMATTED_LOC" >> $GITHUB_ENV
- name: Commit and Push
run: |
git config user.name "Ares-Bot"