Skip to content

fix: support crit pull across gh CLI versions#299

Merged
tomasz-tomczyk merged 2 commits intotomasz-tomczyk:mainfrom
omry:pr299
Apr 18, 2026
Merged

fix: support crit pull across gh CLI versions#299
tomasz-tomczyk merged 2 commits intotomasz-tomczyk:mainfrom
omry:pr299

Conversation

@omry
Copy link
Copy Markdown
Contributor

@omry omry commented Apr 17, 2026

GitHub CLI added gh api --slurp in v2.48.0, but older installs
still need to fetch paginated PR comments successfully.

Detect whether the local gh supports --slurp and use the native
--paginate --slurp path when available. For older gh versions, fall
back to --paginate --jq .[] and decode the streamed JSON objects.

This keeps crit pull working on both pre-2.48.0 and newer gh releases,
with a TODO to remove the compatibility branch once Crit requires
gh v2.48.0+.

GitHub CLI added `gh api --slurp` in v2.48.0, but older installs
still need to fetch paginated PR comments successfully.

Detect whether the local `gh` supports `--slurp` and use the native
`--paginate --slurp` path when available. For older gh versions, fall
back to `--paginate --jq .[]` and decode the streamed JSON objects.

This keeps `crit pull` working on both pre-2.48.0 and newer gh releases,
with a TODO to remove the compatibility branch once Crit requires
`gh v2.48.0+`.
Copilot AI review requested due to automatic review settings April 17, 2026 14:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR keeps crit pull compatible across GitHub CLI versions by detecting whether the locally installed gh supports gh api --slurp (added in v2.48.0) and selecting the appropriate pagination/decoding strategy.

Changes:

  • Add gh version parsing helpers to detect --slurp support based on installed GitHub CLI version.
  • Split PR comment fetching into --paginate --slurp (newer gh) vs --paginate --jq .[] with streamed-object decoding (older gh).
  • Add unit tests covering gh version output parsing for --slurp support.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
github.go Adds version detection and a fallback pagination+decode path so PR comments can be fetched on pre-2.48.0 gh installs.
github_test.go Adds tests validating version-output parsing for determining --slurp availability.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

tomasz-tomczyk commented Apr 17, 2026

Thank you for the contribution! I checked and 2.48.0 has been out for 2 years now so I feel it's fair to say one should just upgrade and we can make it explicit that we require that version or above. Are there any compatibility issues you found that prevent upgrading gh for you?

If there's no issues per se and you just got thrown off by it not working with the older version, I'd be happy to accept a PR that instead makes it clear to the user/throws an error/somehow makes it obvious it's required?

@omry
Copy link
Copy Markdown
Contributor Author

omry commented Apr 18, 2026

The main issue is that on Ubuntu 24.04 LTS, installing gh via the default apt package currently gives an older version (2.45.0), which is still below the 2.48.0 release that added gh api --slurp.

So this is not just about me personally not upgrading - users doing a normal apt install gh on the current Ubuntu LTS can still run into it.

I agree that requiring gh >= 2.48.0 is reasonable. If you prefer not to carry the compatibility code, then a clear version check with an actionable error message would still be a good improvement.

Use errors.Is(err, io.EOF) instead of direct comparison,
which is idiomatic Go since 1.13 and defensive against
future error wrapping.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Ok, that is a compatibility issue then! Thanks for clarifying, will merge 💜 💙 💚

@tomasz-tomczyk tomasz-tomczyk merged commit 3b2eef7 into tomasz-tomczyk:main Apr 18, 2026
4 checks passed
@omry omry deleted the pr299 branch April 18, 2026 10:07
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.

3 participants