Fix gh-pages publish leaving stale worktrees on identity failure#14048
Merged
Fix gh-pages publish leaving stale worktrees on identity failure#14048
Conversation
Validate git user identity (name/email) before creating the publish worktree, and use `--force` on worktree removal to handle dirty state. Also checks GIT_AUTHOR_*/GIT_COMMITTER_* environment variables as fallback, matching git's own identity resolution behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
git user.nameoruser.emailis not configured,quarto publish gh-pagescreates a worktree, attempts a commit inside it, and fails. The worktree is left behind, and subsequent publish attempts also fail because the stale worktree still exists.Root Cause
The publish workflow creates a git worktree for the gh-pages branch, copies rendered output into it, then commits and pushes. If the commit fails (e.g., missing identity), the worktree cleanup in the
finallyblock can also fail because the worktree contains modified/untracked files thatgit worktree remove(without--force) refuses to delete.Fix
Validate git user identity before creating the worktree, failing early with actionable guidance. The check covers
git config user.name/user.emailandGIT_AUTHOR_*/GIT_COMMITTER_*environment variables as fallback.Additionally, both
git worktree removecalls now use--forceto handle dirty worktree state, making cleanup robust regardless of failure cause.Fixes #14046