Skip to content

Conversation

@cho-m
Copy link
Member

@cho-m cho-m commented Nov 9, 2025

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

  • 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

I think this should help with:

* `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
Copilot AI review requested due to automatic review settings November 9, 2025 22:52
Copy link
Contributor

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 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_commit to 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_commit caching 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.

Copilot AI review requested due to automatic review settings November 9, 2025 23:04
@cho-m cho-m force-pushed the fix-github-commit-checks branch from 36dc3ae to 9306c37 Compare November 9, 2025 23:06
Copy link
Contributor

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

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 cho-m force-pushed the fix-github-commit-checks branch from 9306c37 to bfb21ea Compare November 9, 2025 23:10
Copilot AI review requested due to automatic review settings November 9, 2025 23:12
@cho-m cho-m force-pushed the fix-github-commit-checks branch from bfb21ea to b6e5109 Compare November 9, 2025 23:12
Copy link
Contributor

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

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.

@cho-m cho-m changed the title Fix GitHub API commit checks Fix GitHub API last commit and short commit check Nov 10, 2025
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a 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.

Copilot AI review requested due to automatic review settings November 10, 2025 12:50
Copy link
Contributor

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

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 cho-m enabled auto-merge November 10, 2025 13:00
@cho-m cho-m added this pull request to the merge queue Nov 10, 2025
Merged via the queue into main with commit 61fcb07 Nov 10, 2025
37 checks passed
@cho-m cho-m deleted the fix-github-commit-checks branch November 10, 2025 13:35
@MikeMcQuaid
Copy link
Member

@cho-m thanks for quick updates!

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