fix(orchestrator): mark a branch done only when pkgmgr deleted it
The cleanup runs pkgmgr branch cleanup --local and offers deletion only for ancestry-merged branches; squash or PR merges stay a dry-run preview. A signed branch whose ref vanished without a pkgmgr delete becomes gone (deleted outside this run, or after an interrupted apply) and is shown apart from deleted and failed; an Unknown --branch answer for a vanished ref repeats the run once without it. Tests run once on unify/skills-20261114 after the merge (operator order 2026-11-14). 🎯 Fix: 88 % 💥 Break: 6 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 83 🚦 Gate: ⛔ fix 88 % < 90, break 6 % > 5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a2a03995cb
commit
23b6d8579c
19 files changed
+1534
-189
No files matched your search
@@ -242,8 +242,40 @@ class HubCase(unittest.TestCase):
|
||||
root = self.outside / "scan"
|
||||
sample = (Path(__file__).parent / fixture).read_text(encoding="utf-8")
|
||||
self.tree_file.write_text(sample.replace("@ROOT@", str(root)), encoding="utf-8")
|
||||
self.write_local_plan(json.loads(self.tree_file.read_text(encoding="utf-8")), {})
|
||||
return root
|
||||
|
||||
def write_local_plan(self, tree: dict, local: dict[str, dict]) -> None:
|
||||
"""Args:
|
||||
tree: a tree file's data; each branch becomes the item `pkgmgr
|
||||
branch cleanup --local --json` plans for it as gc.py
|
||||
_local_actions does: a merged-clean local branch without
|
||||
worktree merged by ancestry gets exactly local-branch, any
|
||||
other merged-clean one the skip pkgmgr gives a tip that is no
|
||||
ancestor of the default branch.
|
||||
local: branch -> fields that replace the modelled ones, for a
|
||||
local tip that is an ancestor while the tree's merged_by,
|
||||
which covers every tip, is not.
|
||||
"""
|
||||
repos = []
|
||||
for entry in tree["repos"]:
|
||||
default = f"refs/remotes/origin/{entry.get('default')}"
|
||||
items = []
|
||||
for item in entry["items"]:
|
||||
if not item["branch"]:
|
||||
continue
|
||||
candidate = item["state"] == "merged-clean" and bool(item["local_sha"]) and not item["worktree"]
|
||||
ancestry = candidate and item["merged_by"] == "ancestor"
|
||||
planned = {
|
||||
"branch": item["branch"], "worktree": item["worktree"], "head": item["head"], "local_sha": item["local_sha"], "remotes": item["remotes"], "upstream": item["upstream"], "state": item["state"],
|
||||
"merged_by": item["merged_by"], "merged_into": default if item["state"] == "merged-clean" else None,
|
||||
"skip": f"merged by {item['merged_by']}, tip is no ancestor of {default}" if candidate and not ancestry else None,
|
||||
"actions": ["local-branch"] if ancestry else [], "result": None,
|
||||
}
|
||||
items.append({**planned, **local.get(item["branch"], {})})
|
||||
repos.append({"repo": entry["path"], "default": default, "merged_into": [], "warnings": [], "items": items})
|
||||
self.tree_file.with_name("local-plan.json").write_text(json.dumps({"repos": repos}), encoding="utf-8")
|
||||
|
||||
def jsonl(self, rows: list[dict]) -> str:
|
||||
return "".join(json.dumps(row) + "\n" for row in rows)
|
||||
|
||||
|
||||
Reference in new issue
Block a user