Repository navigation
Make less API calls when syncing a stack - #609
Open
nickborromeo wants to merge 7 commits into
Open
nickborromeo wants to merge 7 commits into
nickborromeo wants to merge 7 commits into
Conversation
This adds a new struct that will hold information so we can store any data from an API pull and reuse it.
The main change that is being proposed here is to lower the number of calls that this function makes via the API. Prior to this change, it was making - 3 full stack listings plus 3 lookups per PR After this change it now just makes - 1 stack fetch plus 1 lookup per PR
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The command help and workflow documentation still place PR refresh after pushing, although it now runs before fast-forwarding and rebasing.
1 open issue
What changed in this PR
Reduces GitHub API calls during stack synchronization by fetching tracked stacks directly and reusing PR data from reconciliation.
Changes:
- Fetch stacks by number instead of scanning all repository stacks.
- Reuse fetched PR data and remove the post-push PR refresh.
- Update mocks and regression tests for direct stack lookups and PR-fetch reuse.
| File | Description |
|---|---|
cmd/utils.go |
Separates PR fetching from applying state and shares reconciliation results. |
cmd/utils_test.go |
Updates tests for numbered stack lookups and fallback behavior. |
cmd/sync.go |
Reuses fetched PR data and makes the post-push step report-only. |
cmd/sync_test.go |
Verifies PR-fetch reuse and updates stack API mocks. |
cmd/submit_test.go |
Adapts submit mocks and expectations to direct stack lookups. |
Review effort: Max
| cfg.Printf("") | ||
| cfg.Printf("Syncing PRs ...") | ||
| _ = syncStackPRs(cfg, s) | ||
| cfg.Printf("Reporting PR status ...") |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

When I was looking through the logic of
runSyncI noticed that we calledsyncStackPRsmultiple times, but we don't really use the result of that call. Since the result is not necessarily needed in the sync process I thought we could just call it once.Another thing that we were doing is to pull all the stacks of the repository, paginated by 100. Each stack has a distinct number, so instead of pulling in all the stacks, we now just pull that stack by its number.
Lastly there is just some small helper functions added in
utils.go