Skip to content

Commit 5ca69e7

Browse files
mac-bridge client: refuse dirty trees; =-joined branch-policy args
Live testing caught both: a leading-dash branch suffix (-b876) was parsed as an option flag, and request_run's 'git add -A' silently absorbed unrelated uncommitted edits into the request branch (they vanished from the original branch on switch-back). Requests are now always built from a committed state. Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>
1 parent fe59339 commit 5ca69e7

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

scripts/mac_bridge/kakeya_mac.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ def _branch_policy_args() -> list:
5353
if not match:
5454
return []
5555
suffix = match.group(1)
56-
return ["--branch-prefix", "AgentMemory/mac-bridge-",
57-
"--branch-suffix", suffix]
56+
# `=`-joined so argparse never mistakes a leading-dash suffix
57+
# (e.g. "-b876") for an option flag.
58+
return ["--branch-prefix=AgentMemory/mac-bridge-",
59+
f"--branch-suffix={suffix}"]
5860

5961

6062
def cmd_doctor(_args) -> int:

scripts/mac_bridge/request_run.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ def main() -> int:
120120
repo_root = Path(_git("rev-parse", "--show-toplevel", capture=True))
121121
original_branch = _git("rev-parse", "--abbrev-ref", "HEAD", capture=True)
122122

123+
# Refuse to build a request from a dirty tree: `git add -A` below
124+
# would silently absorb unrelated uncommitted edits into the
125+
# request branch and they would vanish from the original branch
126+
# when we switch back (observed in live testing). The workload is
127+
# always a committed state.
128+
dirty = _git("status", "--porcelain", capture=True)
129+
if dirty:
130+
print("[mac-bridge] working tree is dirty; commit or stash first:\n"
131+
+ dirty, file=sys.stderr)
132+
return 2
133+
123134
# Snapshot bridge files from the CLIENT checkout before switching:
124135
# the workload ref may predate the bridge.
125136
overlay = {

0 commit comments

Comments
 (0)