Skip to content

fix: rm -rf before restoring .github/workflows, not just checkout -- - #59

Merged
solderzzc merged 1 commit into
mainfrom
fix/upstream-sync-restore-new-workflow-files
Aug 16, 2026
Merged

fix: rm -rf before restoring .github/workflows, not just checkout --#59
solderzzc merged 1 commit into
mainfrom
fix/upstream-sync-restore-new-workflow-files

Conversation

@solderzzc

Copy link
Copy Markdown
Member

Summary

#58's restoration step (`git checkout origin/main -- .github/workflows`) looked right but doesn't actually work for the case that caused the original bug. Verified by manually triggering the workflow after #58 merged — it failed again, identical rejection:

```
! [remote rejected] sync/upstream-latest -> sync/upstream-latest (refusing to allow a GitHub App to create or update workflow `.github/workflows/integration_tests.yml` without `workflows` permission)
```

Root cause

`git checkout -- ` only overwrites paths that already exist in ``. It does not delete a file that's present in the working tree/index but absent from `` — so a brand-new workflow file the merge just pulled in from upstream (which `origin/main` never had) survives the "restore" step untouched, and the push still gets rejected for it. This is exactly the upstream-added-a-new-workflow-file scenario that caused the bug in the first place.

Fix

`rm -rf .github/workflows` before the restore checkout, then `git add -A` to also stage the deletion (the checkout alone doesn't unstage a path that's absent from the target ref).

Verification

Reproduced the exact scenario in a throwaway local git sandbox (origin lacks a file, upstream adds a new one, merge, restore):

  • Without `rm -rf`: restore step is a silent no-op, new file survives, push would still fail.
  • With `rm -rf`: new file correctly staged for deletion, restore actually restores.

Also applies the identical fix to `mlx-swift`'s sibling workflow (PR here), which has the same latent bug — it just hasn't hit it yet because upstream mlx-swift hasn't added a new workflow file recently.

Test plan

  • After merge, trigger `workflow_dispatch` and confirm it actually succeeds this time (not just parses).

#58's restoration step (git checkout origin/main -- .github/workflows)
looked right but was a no-op for exactly the case that matters: a
workflow_dispatch run just failed again with the identical
integration_tests.yml rejection.

git checkout <ref> -- <path> only overwrites paths that already exist
in <ref>. It doesn't delete files present in the working tree/index
but absent from <ref> — so a brand-new file the merge just pulled in
from upstream (origin/main never had it) survives untouched, and the
push still gets rejected for it.

Verified locally with a throwaway git sandbox reproducing the exact
scenario (origin lacks a file, upstream adds it, merge, restore):
without rm -rf first, the restore step produces a zero-diff commit and
the new file is still there; with it, the file is correctly staged for
deletion and the restore actually restores.
@solderzzc
solderzzc merged commit 9991db4 into main Aug 16, 2026
6 checks passed
@solderzzc
solderzzc deleted the fix/upstream-sync-restore-new-workflow-files branch August 16, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant