-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Fix GitHub API last commit and short commit check #21009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* `multiple_short_commits_exist?` seems to be checking for some nonexistent string. Instead just put the http_code on stdout. * `last_commit` curl output is now lowercase so just do case-insensitive match. If this breaks again, can consider using API.open_rest instead. * `last_commit` was also outputting a full commit which doesn't work well with other parts of brew. GitHub API does not provide a good way to get the short commit so just attempt a guess at 7 characters. * For GitHub download strategy, handle the case where `last_commit` fails and the repository isn't locally available
There was a problem hiding this 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 improves the handling of Git commit hashes from the GitHub API by standardizing on 7-character short commits and adding better validation and ambiguity detection. The key changes include truncating commit hashes to 7 characters to match GitHub's GraphQL abbreviatedOid format, checking for ambiguous short commits using the GitHub API, and refactoring the caching logic in the download strategy to avoid caching empty strings when repositories haven't been fetched.
Key Changes
- Modified
GitHub.last_committo truncate commit hashes to 7 characters and verify they are unambiguous - Updated
GitHub.multiple_short_commits_exist?to use curl's HTTP status code output for more reliable ambiguity detection - Refactored
GitHubGitDownloadStrategy.last_commitcaching logic to separate GitHub API and local git command results
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Library/Homebrew/utils/github.rb | Added commit hash truncation to 7 characters, case-insensitive ETag regex, ambiguity checking, and improved HTTP status code detection in multiple_short_commits_exist? |
| Library/Homebrew/download_strategy.rb | Refactored last_commit method to avoid caching empty strings and added fallback logic in commit_outdated? for empty commit values |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
36dc3ae to
9306c37
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9306c37 to
bfb21ea
Compare
Co-authored-by: Copilot <[email protected]>
bfb21ea to
b6e5109
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @cho-m! Some minor tweaks then good to ship without a re-review.
Co-authored-by: Mike McQuaid <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@cho-m thanks for quick updates! |
brew stylewith your changes locally?brew typecheckwith your changes locally?brew testswith your changes locally?multiple_short_commits_exist?seems to be checking for some nonexistent string. Instead just put the http_code on stdout.last_commitcurl output is now lowercase so just do case-insensitive match. If this breaks again, can consider using API.open_rest instead.last_commitwas also outputting a full commit which doesn't work well with other parts of brew. GitHub API does not provide a good way to get the short commit so just attempt a guess at 7 characters.last_commitfails and the repository isn't locally availableI think this should help with: