Skip to content

Commit 6971796

Browse files
committed
Copilot feedback
1 parent 77cf88b commit 6971796

5 files changed

Lines changed: 15 additions & 9 deletions

File tree

scripts/bash/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ find_feature_dir_by_prefix() {
133133
else
134134
# Multiple matches - this shouldn't happen with proper naming convention
135135
echo "ERROR: Multiple spec directories found with prefix '$prefix': ${matches[*]}" >&2
136-
echo "Please ensure only one spec directory exists per numeric prefix." >&2
136+
echo "Please ensure only one spec directory exists per prefix." >&2
137137
return 1
138138
fi
139139
}

scripts/bash/create-new-feature.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ done
6969

7070
FEATURE_DESCRIPTION="${ARGS[*]}"
7171
if [ -z "$FEATURE_DESCRIPTION" ]; then
72-
echo "Usage: $0 [--json] [--short-name <name>] [--number N] <feature_description>" >&2
72+
echo "Usage: $0 [--json] [--short-name <name>] [--number N] [--timestamp] <feature_description>" >&2
7373
exit 1
7474
fi
7575

scripts/powershell/create-new-feature.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if ($Help) {
3333

3434
# Check if feature description provided
3535
if (-not $FeatureDescription -or $FeatureDescription.Count -eq 0) {
36-
Write-Error "Usage: ./create-new-feature.ps1 [-Json] [-ShortName <name>] <feature description>"
36+
Write-Error "Usage: ./create-new-feature.ps1 [-Json] [-ShortName <name>] [-Number N] [-Timestamp] <feature description>"
3737
exit 1
3838
}
3939

@@ -96,7 +96,7 @@ function Get-HighestNumberFromBranches {
9696
$cleanBranch = $branch.Trim() -replace '^\*?\s+', '' -replace '^remotes/[^/]+/', ''
9797

9898
# Extract feature number if branch matches pattern ###-*
99-
if ($cleanBranch -match '^(\d+)-') {
99+
if ($cleanBranch -match '^(\d{3})-') {
100100
$num = [int]$matches[1]
101101
if ($num -gt $highest) { $highest = $num }
102102
}

tests/test_branch_numbering.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,24 @@ def test_invalid_branch_numbering_rejected(self, tmp_path: Path):
5151
assert result.exit_code == 1
5252
assert "Invalid --branch-numbering" in result.output
5353

54-
def test_valid_branch_numbering_sequential(self, tmp_path: Path):
54+
def test_valid_branch_numbering_sequential(self, tmp_path: Path, monkeypatch):
5555
from typer.testing import CliRunner
5656
from specify_cli import app
5757

58+
monkeypatch.setattr("specify_cli.download_and_extract_template", lambda *args, **kwargs: None)
59+
5860
runner = CliRunner()
5961
result = runner.invoke(app, ["init", str(tmp_path / "proj"), "--ai", "claude", "--branch-numbering", "sequential"])
60-
# Should not fail on validation (may fail later due to network/template fetch)
62+
assert result.exit_code == 0
6163
assert "Invalid --branch-numbering" not in (result.output or "")
6264

63-
def test_valid_branch_numbering_timestamp(self, tmp_path: Path):
65+
def test_valid_branch_numbering_timestamp(self, tmp_path: Path, monkeypatch):
6466
from typer.testing import CliRunner
6567
from specify_cli import app
6668

69+
monkeypatch.setattr("specify_cli.download_and_extract_template", lambda *args, **kwargs: None)
70+
6771
runner = CliRunner()
6872
result = runner.invoke(app, ["init", str(tmp_path / "proj"), "--ai", "claude", "--branch-numbering", "timestamp"])
69-
# Should not fail on validation (may fail later due to network/template fetch)
73+
assert result.exit_code == 0
7074
assert "Invalid --branch-numbering" not in (result.output or "")

tests/test_timestamp_branches.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def no_git_dir(tmp_path: Path) -> Path:
5151
return tmp_path
5252

5353

54-
def run_script(cwd: Path, *args: str, capture_stderr: bool = False) -> subprocess.CompletedProcess:
54+
def run_script(cwd: Path, *args: str) -> subprocess.CompletedProcess:
5555
"""Run create-new-feature.sh with given args."""
5656
cmd = ["bash", "scripts/bash/create-new-feature.sh", *args]
5757
return subprocess.run(
@@ -91,6 +91,7 @@ def test_timestamp_creates_branch(self, git_repo: Path):
9191
def test_number_and_timestamp_warns(self, git_repo: Path):
9292
"""Test 3: --number + --timestamp warns and uses timestamp."""
9393
result = run_script(git_repo, "--timestamp", "--number", "42", "--short-name", "feat", "Feature")
94+
assert result.returncode == 0, result.stderr
9495
assert "Warning" in result.stderr and "--number" in result.stderr
9596

9697
def test_json_output_keys(self, git_repo: Path):
@@ -209,6 +210,7 @@ class TestNoGitTimestamp:
209210
def test_no_git_timestamp(self, no_git_dir: Path):
210211
"""Test 13: No-git repo + timestamp creates spec dir with warning."""
211212
result = run_script(no_git_dir, "--timestamp", "--short-name", "no-git-feat", "No git feature")
213+
assert result.returncode == 0, result.stderr
212214
spec_dirs = list((no_git_dir / "specs").iterdir()) if (no_git_dir / "specs").exists() else []
213215
assert len(spec_dirs) > 0, "spec dir not created"
214216
assert "git" in result.stderr.lower() or "warning" in result.stderr.lower()

0 commit comments

Comments
 (0)