Skip to content

Treat GIT_BRANCH_NAME naming the current branch as a no-op - #5006

Open
drakeo338 wants to merge 2 commits into
github:mainfrom
drakeo338:claude/5003-fix
Open

drakeo338 wants to merge 2 commits into
github:mainfrom
drakeo338:claude/5003-fix

Conversation

@drakeo338

Copy link
Copy Markdown

Fixes #5003.

Description

With GIT_BRANCH_NAME set to the branch that is already checked out, git checkout -b fails, so the feature-branch script reported "Branch already exists" and exited 1 unless --allow-existing-branch was passed. The branch is already in the requested state, so the bash, PowerShell and Python scripts now succeed without switching, as the --allow-existing-branch path does. A GIT_BRANCH_NAME naming a different existing branch still fails.

Testing

Existing and new tests in the git extension suites: 129 passed, 0 failed (the new tests fail without the fix). I did not run the other checks.

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest
  • Tested with a sample project (if applicable)

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (fill in the disclosure below)

AI disclosure: Code and tests written by Claude Code (model: Claude Sonnet 5.5, autonomous), reviewed by two further agent passes.

Assisted-by: Claude Code (model: Claude Sonnet 5.5, autonomous)

When GIT_BRANCH_NAME names the branch that is already checked out,
`git checkout -b` fails and the script reported "Branch already exists"
and exited 1, unless --allow-existing-branch was passed. The branch is
already in the requested state, so handle it the way the
--allow-existing-branch path does and succeed without switching.

Applied to the bash, PowerShell and Python scripts. A GIT_BRANCH_NAME
naming a different existing branch still fails.

Fixes github#5003

Assisted-by: Claude Code (model: Claude Sonnet 5.5, autonomous)
Add a PowerShell twin of the bash test for GIT_BRANCH_NAME naming the
checked-out branch, use a case-sensitive comparison in the new
PowerShell clause so a differently-cased branch is not mistaken for the
current one, and document the behaviour in speckit.git.feature.md.

Assisted-by: Claude Code (model: Claude Sonnet 5.5, autonomous)
@drakeo338
drakeo338 requested a review from mnriem as a code owner October 17, 2026 14:24

This branch has not been deployed

No deployments
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.

[Bug]: GIT_BRANCH_NAME naming the current branch fails the mandatory before_specify hook

1 participant