From 44cbf070fca2d55baa4fd2a2b2e5517dac888e09 Mon Sep 17 00:00:00 2001 From: alt-glitch Date: Wed, 11 Nov 2026 12:56:08 +0000 Subject: [PATCH] fix(move): migrate-branch --continue keeps unstaged edits and --push refuses a slashed default branch --continue stops when tracked files have unstaged changes, which the import rewrite step would discard. --push compares the branch with the remote default branch's full name, so release/stable is refused too. --- scripts/move/migrate_branch.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/move/migrate_branch.py b/scripts/move/migrate_branch.py index 44023ead24..489f069b7e 100755 --- a/scripts/move/migrate_branch.py +++ b/scripts/move/migrate_branch.py @@ -528,7 +528,7 @@ def push_target(branch: str) -> list[str]: if remote == "." or git("remote", "get-url", remote, check=False).returncode != 0: raise Stop(f"--push: {branch} has no remote to push to (found {remote!r}); push it yourself afterwards.") head = git("symbolic-ref", "-q", f"refs/remotes/{remote}/HEAD", check=False).stdout.strip() - if branch in {head.rsplit("/", 1)[-1] if head else "", "main", "master"}: + if branch in {head.removeprefix(f"refs/remotes/{remote}/") if head else "", "main", "master"}: raise Stop(f"--push: {branch} is the default branch of {remote}; migrate a feature branch instead.") return [remote, f"refs/heads/{branch}"] @@ -566,6 +566,9 @@ def resume(accept_flags: bool) -> dict: state["accept_flags"] = state["accept_flags"] or accept_flags if out("diff", "--name-only", "--diff-filter=U"): raise Stop("Unmerged files remain; resolve them and `git add` them first.") + if "pending_rewrite" not in state and git("diff", "--quiet", check=False).returncode != 0: + raise Stop("Tracked files have unstaged changes, which the next step would discard; " + "`git add` or stash them first.") if git("rev-parse", "-q", "--verify", "MERGE_HEAD", check=False).returncode == 0: git("commit", "--no-edit") elif pending := state.pop("pending_rewrite", None):