Repository navigation
Description
Problem
create_branch (src/devops_cli/git/operations.py:224-231) runs repo.git.checkout("-b", "--", branch_name) at :231. Git's -b takes the next argument as the new branch's name, so git tries to create a branch called -- that starts at branch_name. The call always fails. With git 2.55.0 in a scratch repository, git checkout -b -- feat/x exits 128 with fatal: 'feat/x' is not a commit and a branch '--' cannot be created from it.
The only caller is devops branches jira <ticket> [--slug] (src/devops_cli/commands/branches.py:90-121, call at :116). There is no devops branches create command. Running devops branches jira PROJ-1 --repo <scratch repo> on the release/v0.2.25 tip (9c879ae) creates no branch. It prints a Rich traceback that ends in GitCommandError: ... cmdline: git checkout -b -- feature/PROJ-1. The traceback appears because jira catches only ValueError (branches.py:119), and GitPython's GitCommandError is not a ValueError. The command has failed this way since create_branch was added in 1b81724 (v0.1.10), because the -- was there from the start.
No test caught it:
tests/test_git_operations.py:147-166mocksgitlib.Repoand asserts the broken argv:assert_called_once_with("-b", "--", "feat/test")at:166.tests/test_branches.py:78patchescreate_branchout of thejiraCLI test.
The leading-hyphen guard (operations.py:226-227) already stops the name from being read as an option, so dropping -- needs no other guard. No other git call in src/ puts -- where an option expects its value. resolve_merge_base runs git merge-base -- <base> <head> (operations.py:361), which works. The other calls put -- before pathspecs, which is what -- is for.
The docs name a command that does not exist, and this issue's title copied that name. docs/cheatsheets/git_and_github.md:23 gives devops branches create feat/my-feature and says it "ensures branch is created off the current active release branch". Neither claim is true: the command does not exist, and create_branch branches from the current HEAD. The same table has two more errors:
:24namesdevops branches cleanup, but the command isclean(branches.py:162-163).:22saysdevops branches listshows upstream tracking and ahead/behind counts. It shows the repository, the branch and a marker on the current branch (branches.py:144-154).
No open item covers this file. #921 corrects hand-written docs but does not list docs/cheatsheets/, and #956 and #843 touch only security_and_ssh.md.
Changes since this issue was written: nothing in create_branch, jira or their tests has changed. #946 (9da1309) and #593 (89cbaa2) edited other functions in operations.py and tests/test_git_operations.py, so the cited lines moved. The checkout call is now at :231 (was cited as :226, which is the guard), and the mocked assertion is at :166 (was :160).
Acceptance criteria
-
create_branchrunsrepo.git.checkout("-b", branch_name)without--. The leading-hyphen guard and theBranchAlreadyExistsErrorcheck stay. - When git refuses to create the branch,
create_branchcatches theGitCommandErrorand raisesGitOperationError(..., operation="branch_create")from it, with git's stderr reason as the message.operations.py:123and:178already re-raise lower-level errors asGitOperationErrorthis way.jiraalready catches this error, becauseGitOperationErroris aValueError(src/devops_cli/exceptions/git.py:15). The user sees one error line and exit code 1. -
tests/test_git_operations.py::test_create_branchuses a real repository with one commit intmp_path, built with the sharedgitfixture (tests/conftest.py:425). It asserts thatcreate_branch(repo, "feat/test")createsfeat/testand leaves it checked out (git branch --show-current). It keeps the leading-hyphen check and checks that an existing branch raisesBranchAlreadyExistsError. The mocked argv assertion is removed. The test fails on the current code. - A CLI test in
tests/test_branches.pyrunsjira PROJ-123 --slug "my feature" --repo <repo>against a real repository, without patchingcreate_branch. It asserts exit code 0 and thatfeature/PROJ-123-my-featureis the current branch. It fails on the current code. - A CLI test runs
jira PROJ-123 --repo <repo>in a real repository that already has a branch namedfeature, so git refusesfeature/PROJ-123(cannot lock ref ... 'refs/heads/feature' exists). It asserts exit code 1 and thatresult.exceptionis aSystemExit, not aGitCommandError. It also asserts that the output contains git's reason and no traceback. - The new tests run git only on local repositories under
tmp_path, with no network. They do not depend on the host'sinit.defaultBranchor git identity. -
docs/cheatsheets/git_and_github.md:22-24namesdevops branches list,devops branches jira <ticket> [--slug]anddevops branches clean, and says what each one does. The file no longer mentionsdevops branches createordevops branches cleanup. -
changelog.d/900.mdrecords the fix under### Fixed.CHANGELOG.mdis not edited. -
uv run devops cipasses. - (person-run) In a scratch repository,
devops branches jira PROJ-1 --slug smokeswitches tofeature/PROJ-1-smoke.
Key questions
- Should the fix use
checkout -b <name>,switch -c <name>or GitPython'screate_head(name).checkout()? (proposed)checkout -b <name>. It is the smallest change, git still checks the ref name and writes the error text, and the leading-hyphen guard already stops the name from being read as an option. - Should
create_branchwrap git's failure, or leave it to the caller? (proposed) Wrap it inGitOperationError. AGENTS.md:393 requires typed domain exceptions,operations.pyalready re-raises host-key and clone-destination errors this way (:123,:178), andjirathen prints the error instead of a traceback without any change tojiraitself. - Should this issue fix the cheat sheet, or leave it to docs: hand-written docs name only commands, options and components that exist #921? (proposed) This issue fixes lines 22-24 only, the
devops branchesrows. The wrong command name in this issue's title came from that table, and no open item covers the file. The rest ofdocs/cheatsheets/is docs: hand-written docs name only commands, options and components that exist #921's to correct, if the owner adds the folder to docs: hand-written docs name only commands, options and components that exist #921's scope. - Should a
devops branches create <name>command be added, since the cheat sheet advertises one? (proposed) No. That would be a new feature, not this defect, andgit switch -calready does the job. File it separately if it is wanted. - Should
create_branchbranch from the active release branch, as the cheat sheet claims? (proposed) No. It branches from the current HEAD, as its docstring says (operations.py:225). The cheat sheet is corrected instead.
Depends on: none.
Order: no ordering constraint. The fix touches git/operations.py (create_branch only), tests/test_git_operations.py, tests/test_branches.py and docs/cheatsheets/git_and_github.md. No other open v0.2.25 to v0.2.29 item edits those parts, so this can land in any v0.2.29 slot.
Related: #787 (the same -- misuse, in git show -- <rev>:<path>; fixed in v0.2.24, and this was found in its review). #921 (hand-written docs; does not list docs/cheatsheets/). #920 (its command-resolution test covers only the knowledge base, and #921 extends it to other docs).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 2, 2026
Grooming (2026-10-02): Priority p2-medium → p1-high.
Checked against the code at the release/v0.2.25 tip.
dan-petty commentedon Oct 2, 2026
Placed in v0.2.29 on 2026-10-02. v0.2.29 holds P1 work that has to land before v0.3.0, which v0.2.25 to v0.2.28 had no room for. Backlog P1 items were ranked by Value, then Effort, with defects and security fixes first at a tie. This item ranked in the top ten, and two of the release's twelve slots stay open for P1 items that surface before then.
dan-petty commentedon Oct 2, 2026
Refined to Ready on 2026-10-02 for v0.2.29. The body was checked claim by claim against release/v0.2.25 at 9c879ae, and a second agent then tried to refute it; every major objection was resolved in a revision. Cited lines were updated for code that moved, and the scope was corrected where merged work changed it. Acceptance criteria were tightened so each fails on the current code, and every key question now has a proposed answer.
dan-petty commentedon Oct 8, 2026
Moved to v0.2.30: v0.2.29 started with more than 12 items, and this was its lowest-ranked unstarted item. (devops roadmap reprioritize)
dan-petty commentedon Oct 8, 2026
Linked: #1399 and #1114. Each wraps a
GitCommandErrorfromgit/operations.pyin aGitOperationErrorwith git's stderr throughmask_secrets; whichever lands later reuses the shape. Found by the 2026-10-08 backlog review.fix(cli): `devops branches create` creates the branch instead of fail…
dan-petty-bot commentedon Oct 9, 2026
What changed
#1460, merged into
release/v0.2.30as 1a07122.6 file(s) changed.
How it was verified
Check runs at 4d86ff8:
Acceptance Criteria of
docs/agent/tasks/task-900-branches-jira-creates-branch.md:create_branchrunsgit checkout -b <name>without--, and the leading-hyphen guard and theBranchAlreadyExistsErrorcheck stay:tests/test_git_operations.py::test_create_branch.create_branchraisesGitOperationErrorwithoperation="branch_create"and git's reason as the message:tests/test_git_operations.py::test_create_branch_raises_gits_reason_when_git_refuses.GitCommandErrorkeeps stderr only pre-formatted ("\n stderr: '...'"). Socreate_branchcallscheckoutin GitPython's documented non-raising mode (with_extended_output=True, with_exceptions=False) and raisesGitOperationErrorfrom git's raw stderr throughmask_secrets. That gives the same argv, the typed error, a one-line message and exit 1, with no exception to chain from.test_create_branchuses a real repository with one commit intmp_path, built with the sharedgitfixture. It asserts thatcreate_branch(repo, "feat/test")leavesfeat/testchecked out (git branch --show-current), keeps the leading-hyphen check, and checks that an existing branch raisesBranchAlreadyExistsError. The mocked argv assertion is gone, and the test failed on the old code.jira PROJ-123 --slug "my feature" --repo <repo>against a real repository exits 0 withfeature/PROJ-123-my-featurechecked out, without patchingcreate_branch:tests/test_branches.py::test_jira_creates_and_checks_out_the_feature_branch. It failed on the old code.jira PROJ-123 --repo <repo>in a repository with a branch namedfeatureexits 1 throughSystemExit, prints git's reason ('refs/heads/feature' exists) and no traceback:tests/test_branches.py::test_jira_prints_gits_reason_when_git_refuses_the_branch. It failed on the old code.tmp_path, with no network. They set-b mainongit initand pass their identity through thegitfixture, so neither the host'sinit.defaultBranchnor its git identity matters.docs/cheatsheets/git_and_github.mdrows 22-24 namedevops branches list [--all],devops branches jira <ticket> [--slug <text>]anddevops branches clean [--dry-run]and say what each does. The file no longer mentionsdevops branches createordevops branches cleanup.changelog.d/900.mdrecords the fix under### Fixed.CHANGELOG.mdanddocs/ROADMAP.mdare not edited.uv run devops cipasses.devops branches jira PROJ-1 --slug smoke, thengit branch --show-current; it printsfeature/PROJ-1-smoke.feat(release): v0.2.30 (#1473)