Repository navigation
Treat GIT_BRANCH_NAME naming the current branch as a no-op #5006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
29e1c29
952e9bc
b7ea53c
3139629
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,7 +145,7 @@ def test_manifest_validates(self): | |
|
|
||
| m = ExtensionManifest(EXT_DIR / "extension.yml") | ||
| assert m.id == "git" | ||
| assert m.version == "1.0.1" | ||
| assert m.version == "1.0.2" | ||
|
|
||
| def test_manifest_commands(self): | ||
| """Manifest declares expected commands.""" | ||
|
|
@@ -500,6 +500,28 @@ def test_branch_template_rejects_slug_before_number(self, tmp_path: Path): | |
| assert "{slug}" in result.stderr | ||
| assert "{number}" in result.stderr | ||
|
|
||
| def test_git_branch_name_override_naming_current_branch_is_noop(self, tmp_path: Path): | ||
| """GIT_BRANCH_NAME equal to the checked-out branch exits 0 without switching.""" | ||
| project = _setup_project(tmp_path) | ||
| subprocess.run( | ||
| ["git", "checkout", "-q", "-b", "feature/PROJ-42-login"], | ||
| cwd=project, check=True, | ||
| ) | ||
| result = _run_bash( | ||
| "create-new-feature-branch.sh", project, | ||
| "--json", "--short-name", "login", "Login page", | ||
| env_extra={"GIT_BRANCH_NAME": "feature/PROJ-42-login"}, | ||
| ) | ||
|
|
||
| assert result.returncode == 0, result.stderr | ||
| data = json.loads(result.stdout) | ||
| assert data["BRANCH_NAME"] == "feature/PROJ-42-login" | ||
| head = subprocess.run( | ||
| ["git", "rev-parse", "--abbrev-ref", "HEAD"], | ||
| cwd=project, capture_output=True, text=True, check=True, | ||
| ).stdout.strip() | ||
| assert head == "feature/PROJ-42-login" | ||
|
|
||
| def test_git_branch_name_override_extracts_number_after_namespace(self, tmp_path: Path): | ||
| """GIT_BRANCH_NAME extracts FEATURE_NUM from a namespaced branch.""" | ||
| project = _setup_project(tmp_path / "app-a") | ||
|
|
@@ -920,6 +942,50 @@ def test_git_branch_name_override_ignores_numeric_namespace_segments(self, tmp_p | |
| assert data["BRANCH_NAME"] == "jdoe/2026-app/042-custom-branch" | ||
| assert data["FEATURE_NUM"] == "042" | ||
|
|
||
| def test_git_branch_name_override_naming_current_branch_is_noop(self, tmp_path: Path): | ||
| """PowerShell GIT_BRANCH_NAME equal to the checked-out branch exits 0 without switching.""" | ||
| project = _setup_project(tmp_path) | ||
| subprocess.run( | ||
| ["git", "checkout", "-q", "-b", "feature/PROJ-42-login"], | ||
| cwd=project, check=True, | ||
| ) | ||
| result = _run_pwsh( | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Answered in #5006 (comment): both cases (current-branch no-op and different-existing-branch rejection) were run under Windows PowerShell 5.1 ( |
||
| "create-new-feature-branch.ps1", project, | ||
| "-Json", "-ShortName", "login", "Login page", | ||
| env_extra={"GIT_BRANCH_NAME": "feature/PROJ-42-login"}, | ||
| ) | ||
|
|
||
| assert result.returncode == 0, result.stderr | ||
| data = json.loads(result.stdout) | ||
| assert data["BRANCH_NAME"] == "feature/PROJ-42-login" | ||
| head = subprocess.run( | ||
| ["git", "rev-parse", "--abbrev-ref", "HEAD"], | ||
| cwd=project, capture_output=True, text=True, check=True, | ||
| ).stdout.strip() | ||
| assert head == "feature/PROJ-42-login" | ||
|
|
||
| def test_git_branch_name_override_naming_other_existing_branch_fails(self, tmp_path: Path): | ||
| """PowerShell GIT_BRANCH_NAME naming a different existing branch is rejected without switching.""" | ||
| project = _setup_project(tmp_path) | ||
| subprocess.run(["git", "branch", "feature/other"], cwd=project, check=True) | ||
| before = subprocess.run( | ||
| ["git", "rev-parse", "--abbrev-ref", "HEAD"], | ||
| cwd=project, capture_output=True, text=True, check=True, | ||
| ).stdout.strip() | ||
| result = _run_pwsh( | ||
| "create-new-feature-branch.ps1", project, | ||
| "-Json", "-ShortName", "login", "Login page", | ||
| env_extra={"GIT_BRANCH_NAME": "feature/other"}, | ||
| ) | ||
|
|
||
| assert result.returncode == 1 | ||
| assert "already exists" in result.stderr | ||
| head = subprocess.run( | ||
| ["git", "rev-parse", "--abbrev-ref", "HEAD"], | ||
| cwd=project, capture_output=True, text=True, check=True, | ||
| ).stdout.strip() | ||
| assert head == before | ||
|
|
||
| def test_git_branch_name_override_without_feature_marker_preserves_full_name(self, tmp_path: Path): | ||
| """PowerShell keeps the full override name when no feature marker exists.""" | ||
| project = _setup_project(tmp_path / "app-a") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answered in #5006 (comment): both cases (current-branch no-op and different-existing-branch rejection) were run under Windows PowerShell 5.1 (
5.1.26100.33648,powershell.exe) on awindows-latestrunner, before and after the change, with the run and workflow file linked. Resolving this thread; please reopen if the evidence falls short.