-
-
Couldn't load subscription status.
- Fork 10.6k
patches audit: add correctors #20943
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
base: main
Are you sure you want to change the base?
Conversation
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 adds automatic correctors for patches audit violations that can be automatically fixed, while removing redundant test cases that are now covered by the corrector tests.
- Adds correctors for GitHub .diff to .patch conversion, GitLab .patch to .diff conversion, and GitHub full_index parameter addition
- Removes redundant test cases for MacPorts Trac HTTP patches and Debian HTTP patches
- Removes the TODO comment indicating correctors were needed
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Library/Homebrew/rubocops/patches.rb | Adds corrector blocks to three patch URL validation rules and removes completed TODO comment |
| Library/Homebrew/test/rubocops/patches_spec.rb | Adds three new corrector tests and removes redundant test cases for HTTP patch URLs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Library/Homebrew/rubocops/patches.rb
Outdated
| if regex_match_group(patch_url_node, %r{https://github.com/[^/]*/[^/]*/commit/[a-fA-F0-9]*\.diff}) | ||
| problem "GitHub patches should end with .patch, not .diff: #{patch_url}" | ||
| problem "GitHub patches should end with .patch, not .diff: #{patch_url}" do |corrector| | ||
| correct = patch_url_node.source.gsub(".diff", ".patch") |
Copilot
AI
Oct 25, 2025
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.
Using gsub could incorrectly replace .diff occurring elsewhere in the URL (e.g., in a repository name like my-diff-tool). Use sub(/.diff\"$/, '.patch\"') to only replace the extension at the end of the URL string.
| correct = patch_url_node.source.gsub(".diff", ".patch") | |
| correct = patch_url_node.source.sub(/\.diff"$/, '.patch"') |
Library/Homebrew/rubocops/patches.rb
Outdated
| if regex_match_group(patch_url_node, %r{.*gitlab.*/commit/[a-fA-F0-9]*\.patch}) | ||
| problem "GitLab patches should end with .diff, not .patch: #{patch_url}" | ||
| problem "GitLab patches should end with .diff, not .patch: #{patch_url}" do |corrector| | ||
| correct = patch_url_node.source.gsub(".patch", ".diff") |
Copilot
AI
Oct 25, 2025
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.
Using gsub could incorrectly replace .patch occurring elsewhere in the URL (e.g., in a repository name). Use sub(/.patch\"$/, '.diff\"') to only replace the extension at the end of the URL string.
| correct = patch_url_node.source.gsub(".patch", ".diff") | |
| correct = patch_url_node.source.sub(/\.patch"$/, '.diff"') |
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.
Auto-correcting the patch URL will invalidate its checksum because the contents are different (as in, .patch shows the commit in email format while .diff shows only the diff). Can that be handled any better?
Just thinking out loud, LGTM besides that. Thanks!
should probably remove the |
Good idea, I also removed it when adding |
brew stylewith your changes locally?brew typecheckwith your changes locally?brew testswith your changes locally?Add correctors for all problems in the patches audit that can be automatically fixed. It also remove a few redundant tests.