Skip to content

Fix gh-pages publish leaving stale worktrees on identity failure#14048

Merged
cderv merged 1 commit intomainfrom
fix/issue-14046
Feb 18, 2026
Merged

Fix gh-pages publish leaving stale worktrees on identity failure#14048
cderv merged 1 commit intomainfrom
fix/issue-14046

Conversation

@cderv
Copy link
Copy Markdown
Member

@cderv cderv commented Feb 17, 2026

When git user.name or user.email is not configured, quarto publish gh-pages creates 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 finally block can also fail because the worktree contains modified/untracked files that git 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.email and GIT_AUTHOR_*/GIT_COMMITTER_* environment variables as fallback.

Additionally, both git worktree remove calls now use --force to handle dirty worktree state, making cleanup robust regardless of failure cause.

Fixes #14046

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>
@posit-snyk-bot
Copy link
Copy Markdown
Collaborator

posit-snyk-bot commented Feb 17, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cscheid cscheid added this to the v1.9 milestone Feb 17, 2026
@cderv cderv merged commit 64192c9 into main Feb 18, 2026
51 checks passed
@cderv cderv deleted the fix/issue-14046 branch February 18, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worktree cleanup problem with gh-pages publishing when wrong git setup iniially

3 participants