Skip to content

Commit 79d870d

Browse files
MattFisherclaude
andcommitted
Lease the template-update push against the fetched branch
A bare --force-with-lease to a URL has no remote-tracking ref to compare against, so the push is refused with "stale info" whenever the update branch already exists. Lease against the ref checkout fetched instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1d8675b commit 79d870d

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎.github/workflows/template-update.yml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,14 @@ jobs:
135135
git checkout -b "$BRANCH"
136136
git add -A
137137
git commit -m "chore: apply template updates from $REF"
138-
git push --force-with-lease \
138+
# The push goes to a URL rather than to `origin`, so a bare
139+
# --force-with-lease has no remote-tracking ref to compare against
140+
# and refuses with "stale info" whenever the branch already exists,
141+
# which is every week after a run that pushed but couldn't open its
142+
# PR. Lease against what checkout fetched instead; empty means the
143+
# branch must not exist yet.
144+
expect=$(git rev-parse -q --verify "refs/remotes/origin/$BRANCH" || true)
145+
git push --force-with-lease="$BRANCH:$expect" \
139146
"https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "$BRANCH"
140147
141148
BODY="Applied by \`copier update --vcs-ref $REF\`."
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Fixed
2+
3+
- `template-update.yml` no longer fails every run once its update branch exists. It pushed with a bare `--force-with-lease` to a URL, which gives git no remote-tracking ref to lease against, so the push was refused with `stale info` whenever the branch was already there. A run that pushed the branch but couldn't open its PR (for example, before the Actions pull-request setting was on) left every later run failing. The push now leases against the branch as checkout fetched it, so it still refuses to overwrite a commit pushed during the run.

0 commit comments

Comments
 (0)