Skip to content

Commit b546b22

Browse files
mavamclaude
andauthored
Fix release recovery instructions showing placeholder branch names (#5)
* Fix release recovery instructions showing placeholder branch names When a release fails during the push_branch step, recovery instructions showed 'git push origin <branch>:<branch>' instead of the actual branch name. Extract branch resolution logic into a new get_push_branch_info() function that returns push info without executing, allowing the step tracker to display accurate commands. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add changelog entry for branch name display fix Resolves: #5 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Format utils.py with ruff --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent a0399be commit b546b22

File tree

3 files changed

+61
-6
lines changed

3 files changed

+61
-6
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: Release recovery instructions show actual branch name
3+
type: bugfix
4+
authors:
5+
- mavam
6+
- claude
7+
pr: 5
8+
created: 2026-01-22T19:01:49.721973Z
9+
---
10+
11+
When a release fails during the branch push step, the recovery instructions now
12+
display the actual branch name instead of a placeholder:
13+
14+
```
15+
╭──────────────────── Release Progress (2/5) ────────────────────╮
16+
│ ✔ git commit -m "Release v1.2.0" │
17+
│ ✔ git tag -a v1.2.0 -m "Release v1.2.0" │
18+
│ ✘ git push origin main:main │
19+
│ ○ git push origin v1.2.0 │
20+
│ ○ gh release create v1.2.0 --repo tenzir/ship ... │
21+
╰────────────────────────────────────────────────────────────────╯
22+
```
23+
24+
Previously, the failed step showed `git push origin <branch>:<branch>` instead
25+
of the actual branch name.

src/tenzir_ship/cli/_release.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
create_git_commit,
3535
emit_output,
3636
format_bold,
37+
get_push_branch_info,
3738
has_staged_changes,
3839
log_info,
3940
log_success,
@@ -573,10 +574,22 @@ def publish_release(
573574
tracker = StepTracker()
574575
if create_commit:
575576
tracker.add("commit", f'git commit -m "{final_commit_message}"')
577+
578+
# Get branch info early for accurate step tracking display
579+
push_remote: str | None = None
580+
push_remote_ref: str | None = None
581+
push_branch: str | None = None
576582
if create_tag:
583+
try:
584+
push_remote, push_remote_ref, push_branch = get_push_branch_info(
585+
project_root, config.repository
586+
)
587+
except RuntimeError as exc:
588+
raise click.ClickException(str(exc)) from exc
589+
577590
tracker.add("tag", f'git tag -a {manifest.version} -m "Release {manifest.version}"')
578-
tracker.add("push_branch", "git push origin <branch>:<branch>")
579-
tracker.add("push_tag", f"git push origin {manifest.version}")
591+
tracker.add("push_branch", f"git push {push_remote} {push_branch}:{push_remote_ref}")
592+
tracker.add("push_tag", f"git push {push_remote} {manifest.version}")
580593
tracker.add("publish", f"gh release create {manifest.version} --repo {config.repository} ...")
581594

582595
def _fail_step_and_raise(step_name: str, exc: Exception) -> NoReturn:
@@ -609,13 +622,11 @@ def _fail_step_and_raise(step_name: str, exc: Exception) -> NoReturn:
609622
log_warning(f"git tag {manifest.version} already exists; skipping creation.")
610623

611624
try:
612-
branch_remote, branch_remote_ref, branch_name = push_current_branch(
613-
project_root, config.repository
614-
)
625+
push_current_branch(project_root, config.repository)
615626
except RuntimeError as exc:
616627
_fail_step_and_raise("push_branch", exc)
617628
tracker.complete("push_branch")
618-
log_success(f"pushed branch {branch_name} to remote {branch_remote}/{branch_remote_ref}.")
629+
log_success(f"pushed branch {push_branch} to remote {push_remote}/{push_remote_ref}.")
619630

620631
try:
621632
remote_name = push_git_tag(project_root, manifest.version, config.repository)

src/tenzir_ship/utils.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,25 @@ def _upstream_branch(project_root: Path) -> Optional[tuple[str, str]]:
548548
return remote_name, branch_name
549549

550550

551+
def get_push_branch_info(project_root: Path, repository: str | None = None) -> tuple[str, str, str]:
552+
"""Return push branch info (remote, remote_ref, branch) without executing.
553+
554+
Raises RuntimeError if HEAD is detached.
555+
"""
556+
branch = _current_branch(project_root)
557+
if not branch:
558+
raise RuntimeError("cannot determine current branch because HEAD is detached.")
559+
560+
upstream = _upstream_branch(project_root)
561+
if upstream:
562+
remote_name, remote_branch = upstream
563+
else:
564+
remote_name = _select_remote_name(project_root, repository)
565+
remote_branch = branch
566+
567+
return remote_name, remote_branch, branch
568+
569+
551570
def push_current_branch(project_root: Path, repository: str | None = None) -> tuple[str, str, str]:
552571
"""Push the current branch to its upstream (or configured) remote."""
553572
branch = _current_branch(project_root)

0 commit comments

Comments
 (0)