From e92ef1e094b4acfa883ade14588bbdfa8b7a9bd3 Mon Sep 17 00:00:00 2001 From: Kyle Date: Mon, 6 Oct 2025 21:06:16 +0800 Subject: [PATCH] Fix: Use git commit --amend when FORCE_PUSH=true to prevent commit accumulation --- Scripts/update-gh-pages-documentation.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Scripts/update-gh-pages-documentation.sh b/Scripts/update-gh-pages-documentation.sh index a76906c46..1c411a72b 100755 --- a/Scripts/update-gh-pages-documentation.sh +++ b/Scripts/update-gh-pages-documentation.sh @@ -257,13 +257,24 @@ if git diff --cached --quiet; then log_info "No changes to documentation" else log_info "Committing documentation changes..." - git commit -m "Update documentation (generated from $CURRENT_BRANCH@$(git -C "$REPO_ROOT" rev-parse --short HEAD))" - log_info "Pushing to gh-pages branch..." if [[ "$FORCE_PUSH" == true ]]; then + # Use --amend to avoid accumulating commits with large binary files + # Check if there are any commits in the branch + if git rev-parse HEAD >/dev/null 2>&1; then + git commit --amend -m "Update documentation (generated from $CURRENT_BRANCH@$(git -C "$REPO_ROOT" rev-parse --short HEAD))" + else + # First commit on the branch + git commit -m "Update documentation (generated from $CURRENT_BRANCH@$(git -C "$REPO_ROOT" rev-parse --short HEAD))" + fi + + log_info "Pushing to gh-pages branch..." log_info "Using --force to save git repo size (avoids accumulating large binary files)" git_push --force origin gh-pages else + git commit -m "Update documentation (generated from $CURRENT_BRANCH@$(git -C "$REPO_ROOT" rev-parse --short HEAD))" + + log_info "Pushing to gh-pages branch..." git_push origin gh-pages fi