Skip to content

Commit 2b0859f

Browse files
committed
fix: preserve literal plus branch prefixes
1 parent bcd7b30 commit 2b0859f

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

extensions/git/scripts/bash/create-new-feature-branch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ get_highest_from_specs() {
127127

128128
# Function to get highest number from git branches
129129
get_highest_from_branches() {
130-
git branch -a 2>/dev/null | sed 's/^[+* ]*//; s|^remotes/[^/]*/||' | _extract_highest_number
130+
git branch -a 2>/dev/null | sed -E 's/^[+*][[:space:]]+//; s/^[[:space:]]+//; s|^remotes/[^/]*/||' | _extract_highest_number
131131
}
132132

133133
# Extract the highest sequential feature number from a list of ref names (one per line).

tests/extensions/git/test_git_extension.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,25 @@ def test_dry_run_counts_branches_checked_out_in_worktrees(self, tmp_path: Path):
338338
assert data["BRANCH_NAME"] == "008-next"
339339
assert data["FEATURE_NUM"] == "008"
340340

341+
def test_dry_run_preserves_literal_plus_branch_prefix(self, tmp_path: Path):
342+
"""A literal leading plus in a branch name is not a git worktree marker."""
343+
project = _setup_project(tmp_path)
344+
subprocess.run(
345+
["git", "branch", "+007-plus-prefix"],
346+
cwd=project,
347+
check=True,
348+
)
349+
350+
result = _run_bash(
351+
"create-new-feature-branch.sh", project,
352+
"--json", "--dry-run", "--short-name", "next", "Next feature",
353+
)
354+
355+
assert result.returncode == 0, result.stderr
356+
data = json.loads(result.stdout)
357+
assert data["BRANCH_NAME"] == "001-next"
358+
assert data["FEATURE_NUM"] == "001"
359+
341360
def test_no_git_graceful_degradation(self, tmp_path: Path):
342361
"""create-new-feature-branch.sh works without git (outputs branch name, skips branch creation)."""
343362
project = _setup_project(tmp_path, git=False)

0 commit comments

Comments
 (0)