Skip to content

Commit f6a87c8

Browse files
authored
fix(stack): surface fetch_old_pr_heads failures instead of swallowing (#1315)
The exception handler around `fetch_old_pr_heads` previously did a silent `pass`, leaving every revision-history entry stamped "unknown" with no clue why. When a real failure happens (fork remote without `refs/pull/N/head`, network error, missing permissions, …) the user has no signal that anything went wrong — they only see the symptom in the PR comment days later. Log the underlying error in orange so the cause is visible at push time. The exception text is run through `rich.markup.escape` so any `[`/`]` in the git error message is rendered literally rather than parsed as Rich markup. Behaviour stays non-fatal: classification still falls back to "unknown" and the push proceeds. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Depends-On: #1316
1 parent b35651e commit f6a87c8

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

mergify_cli/stack/push.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import sys
2525
import typing
2626

27+
import rich.markup
28+
2729
from mergify_cli import console
2830
from mergify_cli import console_error
2931
from mergify_cli import utils
@@ -582,8 +584,16 @@ async def stack_push(
582584
with console.status("Fetching old PR heads for comparison..."):
583585
try:
584586
await fetch_old_pr_heads(remote, updated_pr_numbers)
585-
except utils.CommandError:
586-
pass # Non-fatal: change type will be "unknown"
587+
except utils.CommandError as exc:
588+
# Non-fatal: change type will be "unknown" — but surface
589+
# the underlying error so the user can fix it. Escape the
590+
# exception text since it can contain `[`/`]` that Rich
591+
# would otherwise interpret as markup tags.
592+
console.log(
593+
f"[orange]Could not fetch old PR heads; revision-history "
594+
f"change types will fall back to 'unknown': "
595+
f"{rich.markup.escape(str(exc))}[/]",
596+
)
587597

588598
# Detect change types before force-push overwrites refs
589599
change_types: dict[str, str] = {}

0 commit comments

Comments
 (0)