Skip to content

Commit bbfeb41

Browse files
shirgoldbirdclaude
andcommitted
fix(ship): branch off HEAD without stashing
ship.py stashed the working tree, created the branch off `main`, then popped the stash back. When the current branch's docs.json had diverged from main (e.g. running on a feature branch mid-restructure), the pop conflicted, crashed the step, and left conflict markers committed into the docs — while stranding the user's real work in a dangling stash. Branch off the CURRENT HEAD instead and drop the stash entirely: the promoted changes already in the working tree carry over with no conflict, and unrelated uncommitted work is never touched. On main (CI, the intended context) HEAD == main, so behavior is unchanged; on a divergent branch it now succeeds safely instead of corrupting state. Verified by reproducing the divergent scenario: branch created off HEAD, docs committed, no stash, exit 0. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e66f59e commit bbfeb41

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

pipeline/ship.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def main():
212212
need_new_branch = current_branch != branch_name
213213

214214
if need_new_branch:
215-
print(f" Will create branch: {branch_name} (off main)")
215+
print(f" Will create branch: {branch_name} (off {current_branch})")
216216
else:
217217
print(f" On branch: {branch_name}")
218218

@@ -242,17 +242,19 @@ def main():
242242
return 0
243243

244244
# --- Create branch ---
245+
# No stashing. Branch off the CURRENT HEAD so the promoted changes already in
246+
# the working tree carry over cleanly. The old approach stashed the working
247+
# tree and popped it onto a branch created off `main`; when the current
248+
# branch's docs.json had diverged from main, that pop conflicted, crashed the
249+
# step, and left conflict markers in the tree. Branching off HEAD applies with
250+
# no conflict and never disturbs unrelated uncommitted work.
245251
if need_new_branch:
246252
if branch_exists(branch_name):
247253
print(f"Switching to existing branch: {branch_name}")
248-
run(["git", "stash", "push", "-m", "pipeline-ship"])
249254
run(["git", "checkout", branch_name])
250-
run(["git", "stash", "pop"])
251255
else:
252-
print(f"Creating branch: {branch_name} (off main)")
253-
run(["git", "stash", "push", "-m", "pipeline-ship"])
254-
run(["git", "checkout", "-b", branch_name, "main"])
255-
run(["git", "stash", "pop"])
256+
print(f"Creating branch: {branch_name} (off {current_branch})")
257+
run(["git", "checkout", "-b", branch_name])
256258

257259
# --- Stage and commit ---
258260
print("Staging docs files...")

0 commit comments

Comments
 (0)