Skip to content

fix(push): chunk git push so stacks > 20 branches don't fail#735

Merged
aviator-app[bot] merged 1 commit intoaviator-co:masterfrom
mvanhorn:osc/638-batch-git-push
May 5, 2026
Merged

fix(push): chunk git push so stacks > 20 branches don't fail#735
aviator-app[bot] merged 1 commit intoaviator-co:masterfrom
mvanhorn:osc/638-batch-git-push

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

Summary

Closes #638.

av sync fails when a stack has more than 20 PRs because GitHub rejects pushes with more than 20 ref updates. The reporter's workaround was manually pushing a few branches to drop under 20 before letting av sync finish.

This splits pushCandidates into chunks of 20 and runs git push --atomic --force-with-lease=... once per chunk. Each chunk is still atomic on its own; only the whole-operation atomicity is relaxed, which is the intended trade-off (no other way to make >20-branch stacks pushable at all).

Files

  • internal/gh/ghui/push.go:
    • New gitPushChunkSize = 20 constant with a comment pointing at Batch updates (hitting gh branch update limits) #638.
    • runGitPush now loops start += gitPushChunkSize over vm.pushCandidates, building per-chunk pushArgs and calling vm.repo.Run once per chunk. Each chunk includes its own --atomic and per-branch --force-with-lease= so safety guarantees inside a chunk are unchanged.

Verification

  • go build ./... clean.
  • go vet ./... clean.
  • go test ./internal/gh/ghui/... passes (no test files in this package, returns "no test files").
  • The pre-existing typecheck warning in internal/gh/ghui/push.go:553 (mapToRemoteTrackingBranch undefined) reproduces on master without these changes and is not introduced by this PR.

Test plan

  • go build ./... clean.
  • Stacks with <= 20 branches still push in a single chunk (loop runs once).
  • Each chunk uses --atomic + --force-with-lease=, preserving safety inside the chunk.
  • Manual: run av sync on a stack with > 20 PRs and confirm all branches push without the GitHub limit error (no fixture in this repo's tests).

Notes

  • Cross-chunk atomicity is relaxed by design. If the first chunk pushes successfully and the second fails, the user is left with a partial push. Same observable behaviour as the reporter's manual workaround.
  • 20 was chosen because it's the documented GitHub limit; if GitHub ever raises it, the constant is the only knob to change.

@mvanhorn mvanhorn requested a review from a team as a code owner April 28, 2026 08:44
@aviator-app
Copy link
Copy Markdown
Contributor

aviator-app Bot commented Apr 28, 2026

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged using Aviator.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

@aviator-app
Copy link
Copy Markdown
Contributor

aviator-app Bot commented Apr 28, 2026

✅ FlexReview Status

Common Owner: aviator-co/engineering (expert-load-balance assignment)
Owner and Assignment:

  • aviator-co/engineering (expert-load-balance assignment)
    Owned Files
    • 🔒 internal/gh/ghui/push.go

Review SLO: 7 business hours if PR size is <= 200 LOC for the first response.

@aviator-app aviator-app Bot requested a review from davi-maciel April 28, 2026 08:44
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a chunking mechanism for git push operations to avoid exceeding GitHub's limit of 20 ref updates per push. The implementation splits the push candidates into smaller batches, ensuring each batch remains atomic. I have no feedback to provide as the changes correctly address the identified issue.

@davi-maciel davi-maciel requested review from tulioz and removed request for davi-maciel April 29, 2026 20:11
…-co#638)

GitHub limits a single git push to 20 ref updates. When users have a
stack with more than 20 PRs, av sync fails because it pushes every
candidate branch in a single git push --atomic invocation. The
issue reporter was working around this by manually pushing a few
branches to drop under 20 before letting av sync finish.

Split pushCandidates into chunks of gitPushChunkSize (20) and run
git push --atomic --force-with-lease=... once per chunk. Each chunk
is still atomic on its own, so a single chunk's lease check failure
still rolls back that chunk. Cross-chunk atomicity is intentionally
relaxed to make >20-branch stacks pushable at all.

No tests in this package today; the chunking math is straightforward
and exercised by every existing av sync against a >0-branch stack.
@tulioz tulioz force-pushed the osc/638-batch-git-push branch from 4208ba4 to 226c18f Compare May 5, 2026 21:31
@aviator-app aviator-app Bot merged commit f77b403 into aviator-co:master May 5, 2026
4 of 5 checks passed
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.

Batch updates (hitting gh branch update limits)

2 participants