Skip to content

Commit 5281451

Browse files
authored
Fix: Use git commit --amend when FORCE_PUSH=true to prevent commit accumulation (#555)
1 parent b73162a commit 5281451

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Scripts/update-gh-pages-documentation.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,24 @@ if git diff --cached --quiet; then
257257
log_info "No changes to documentation"
258258
else
259259
log_info "Committing documentation changes..."
260-
git commit -m "Update documentation (generated from $CURRENT_BRANCH@$(git -C "$REPO_ROOT" rev-parse --short HEAD))"
261260

262-
log_info "Pushing to gh-pages branch..."
263261
if [[ "$FORCE_PUSH" == true ]]; then
262+
# Use --amend to avoid accumulating commits with large binary files
263+
# Check if there are any commits in the branch
264+
if git rev-parse HEAD >/dev/null 2>&1; then
265+
git commit --amend -m "Update documentation (generated from $CURRENT_BRANCH@$(git -C "$REPO_ROOT" rev-parse --short HEAD))"
266+
else
267+
# First commit on the branch
268+
git commit -m "Update documentation (generated from $CURRENT_BRANCH@$(git -C "$REPO_ROOT" rev-parse --short HEAD))"
269+
fi
270+
271+
log_info "Pushing to gh-pages branch..."
264272
log_info "Using --force to save git repo size (avoids accumulating large binary files)"
265273
git_push --force origin gh-pages
266274
else
275+
git commit -m "Update documentation (generated from $CURRENT_BRANCH@$(git -C "$REPO_ROOT" rev-parse --short HEAD))"
276+
277+
log_info "Pushing to gh-pages branch..."
267278
git_push origin gh-pages
268279
fi
269280

0 commit comments

Comments
 (0)