feat: restrict upstream merge to published GitHub releases only#150
Merged
anandgupta42 merged 4 commits intomainfrom Mar 15, 2026
Merged
feat: restrict upstream merge to published GitHub releases only#150anandgupta42 merged 4 commits intomainfrom
anandgupta42 merged 4 commits intomainfrom
Conversation
- Add `script/upstream/utils/github.ts` — GitHub Releases API utilities that fetch, validate, and list published releases via `gh` CLI - Remove `--commit` flag from merge.ts — arbitrary commit merges no longer allowed - Add `--include-prerelease` flag for both `merge.ts` and `list-versions.ts` - Replace git tag listing with GitHub Releases API in `list-versions.ts` - Validate versions against GitHub releases before merging (not just git tags) - Fix: `validateRelease()` accepts `includePrerelease` option to properly support the `--include-prerelease` flag (caught by multi-model code review) - Fix: Remove duplicate `getRelease()` call (dead code) in `validateRelease()` - Add 46 tests covering GitHub API utilities, release validation, and structural enforcement of the release-only policy Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6c8b4c4 to
e32c2b1
Compare
`gh api --paginate` outputs concatenated JSON arrays (`[...][...]`) when results span multiple pages, which `JSON.parse` cannot handle. Use `--slurp` to combine all pages into a single array, then `flatten` the result before filtering. Also reorders the jq pipeline to filter before slicing, so `--limit N` returns N stable releases rather than N total (which could include pre-releases that get filtered out). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
`gh api` does not support `--slurp` — it's a jq-only flag. Instead, use `--jq '.[]'` to unpack each page's array into individual JSON objects, then pipe to external `jq -s` to slurp them into a single array for filtering and slicing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The `limit` from CLI args was not passed to `fetchReleases`, so it always defaulted to 100 internally. Now `list-versions.ts` passes the limit through, and `--all` passes `undefined` to skip the jq slice. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
anandgupta42
added a commit
that referenced
this pull request
Mar 17, 2026
* feat: restrict upstream merge to published GitHub releases only - Add `script/upstream/utils/github.ts` — GitHub Releases API utilities that fetch, validate, and list published releases via `gh` CLI - Remove `--commit` flag from merge.ts — arbitrary commit merges no longer allowed - Add `--include-prerelease` flag for both `merge.ts` and `list-versions.ts` - Replace git tag listing with GitHub Releases API in `list-versions.ts` - Validate versions against GitHub releases before merging (not just git tags) - Fix: `validateRelease()` accepts `includePrerelease` option to properly support the `--include-prerelease` flag (caught by multi-model code review) - Fix: Remove duplicate `getRelease()` call (dead code) in `validateRelease()` - Add 46 tests covering GitHub API utilities, release validation, and structural enforcement of the release-only policy Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: handle paginated `gh api` output with `--slurp` in `fetchReleases` `gh api --paginate` outputs concatenated JSON arrays (`[...][...]`) when results span multiple pages, which `JSON.parse` cannot handle. Use `--slurp` to combine all pages into a single array, then `flatten` the result before filtering. Also reorders the jq pipeline to filter before slicing, so `--limit N` returns N stable releases rather than N total (which could include pre-releases that get filtered out). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: replace `--slurp` with `jq -s` pipe for `gh api` pagination `gh api` does not support `--slurp` — it's a jq-only flag. Instead, use `--jq '.[]'` to unpack each page's array into individual JSON objects, then pipe to external `jq -s` to slurp them into a single array for filtering and slicing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: pass CLI `--limit`/`--all` to `fetchReleases` The `limit` from CLI args was not passed to `fetchReleases`, so it always defaulted to 100 internally. Now `list-versions.ts` passes the limit through, and `--all` passes `undefined` to skip the jq slice. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
What does this PR do?
Restricts the upstream merge tooling to only allow merging from published GitHub releases, replacing the previous system that accepted arbitrary commits or git tags.
script/upstream/utils/github.ts— GitHub Releases API utilities (fetch, validate, list releases viaghCLI)--commitflag frommerge.ts— no more arbitrary commit merges--include-prereleaseflag for bothmerge.tsandlist-versions.tslist-versions.tsnow uses GitHub Releases API instead of raw git tagsvalidateRelease()properly supports--include-prereleaseflag (caught by 6-model code review)getRelease()call invalidateRelease()Type of change
Issue for this PR
Closes #17642
How did you verify your code works?
bun test test/upstream/) covering:execSync)includePrereleaseoption--commit, importsvalidateRelease, etc.)turbo typecheck)Checklist
🤖 Generated with Claude Code