Skip to content

fix(update): stop leasing the default branch in ref updates - #81

Merged
sweepies merged 2 commits into
mainfrom
fix/no-default-branch-lease
Oct 30, 2026
Merged

sweepies merged 2 commits into
mainfrom
fix/no-default-branch-lease

Conversation

@sweepies

@sweepies sweepies commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Cause

Every GraphQL updateRefs call included a no-op lease entry for the default branch (beforeOid = afterOid = the base commit). On a repository whose default branch has a "Require a pull request before merging" ruleset, GitHub treats that entry as a push to the default branch and rejects it. updateRefs is atomic, so one rejection failed every branch in the batch with atomic batch ref lease failed … GitHub GraphQL returned errors.

Fix

  • The default-branch entry is removed from all three updateRefs inputs: the batch publish (chunks are now 50 branch refs, and the empty-batch skip is refs.is_empty()), the single-branch publish, and obsolete-branch deletion.
  • Each branch keeps its own beforeOid lease, so a concurrent push to an update branch is still refused.
  • prepare() still refuses a moved base when it reads the head. A branch left behind by a base that moves afterwards is rebased on the next run.
  • delete_owned loses its base parameter, and the auto-merge caller no longer reads the merge response's sha for it. Nothing else used them.
  • Error::Graphql now carries GitHub's errors[].message values, joined with "; " and truncated to 300 characters, so a failure reads GitHub GraphQL returned errors: Push blocked …. Only the message text is kept, not request data.

Tests

  • no_ref_update_names_the_default_branch checks that the single-branch publish, the batch publish and cleanup never name the default branch. batch_ref_race_keeps_every_prepared_branch_unpublished now expects 2 refs, not 3. Both fail without the fix.
  • The batch and single-branch race tests assert that GitHub's message reaches the action's error text. A unit test covers joining and truncation.
  • fixtures/github/graphql-errors.json has two messages, and the offline test asserts they are carried and that the token and non-message fields are not.
  • No cassette records an updateRefs body. These paths are tested against in-process fakes.

Docs

guide/pull-requests.md, guide/how-it-works.mdx and internals/engine.md say leases are on the branch only, and why the default branch is not named.

Refs #79

View guided diff Turn on auto-fix

Every `updateRefs` call carried a no-op lease entry for the default
branch. Rulesets that require a pull request treat that entry as a push to
the default branch and reject it, and because `updateRefs` is atomic, every
branch in the batch failed with it.

Drop the default-branch entry from the batch publish, the single-branch
publish and obsolete-branch deletion. Each branch keeps its own `beforeOid`
lease, and `prepare()` still refuses a moved base when it reads the head.

`Error::Graphql` now carries GitHub's `errors[].message` values (joined with
"; ", truncated to 300 characters), so a failed update says why.

Refs #79
@deepsource-io

deepsource-io Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 316fb66...eb4c0ea on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Rust Oct 30, 2026 9:11p.m. Review ↗
JavaScript Oct 30, 2026 9:11p.m. Review ↗
Shell Oct 30, 2026 9:11p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 11 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread crates/update/src/cleanup.rs Resolved
Comment thread crates/update/src/write.rs Resolved
@context7

context7 Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Docs7 for sweepies/count-patchula

Result Status Action
Deployment ➖ Not used —
Content review ➖ Did not run. This site has no agent runs available this month. Wait for the monthly reset or check your Docs7 plan. —

Commit eb4c0ea

…read

Deleting obsolete branches no longer leases the default branch, so check
its head just before deleting and leave cleanup to the next run if it
moved. Also correct the ref update docs: a branch left behind by a moved
base follows prs.rebase on the next run.

Refs #79
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula eb4c0ea Commit Preview URL

Branch Preview URL
Oct 30 2026, 09:11 PM

@sweepies
sweepies merged commit b50f62d into main Oct 30, 2026
17 checks passed
@sweepies
sweepies deleted the fix/no-default-branch-lease branch October 30, 2026 22:11
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