Skip to content
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

Add closed PR check to bump cmds #14396

Merged

Conversation

apainintheneck
Copy link
Contributor

  • 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?

This fixes #14336 where we found out that the brew bump command was failing when there already existed a closed PR that tried to update the package to the same version. This recommended passing the --force flag which the brew bump command doesn't allow. This is expected behavior in bump-formula-pr that wasn't addressed in brew bump. The change here is to check for closed PRs in the brew bump command first and not allow users to force any PRs from that command because it's a convenience command for brew bump-cask-pr and brew bump-formula-pr. It also adds the closed PR check to brew bump-cask-pr to match the formula version of the same command.

The reason why we don't want people bumping packages that have a closed PR is because that means it was either already merged in or it requires some sort of extra attention that caused the bump to fail the first time.

One thing to keep in mind is that this will increase the number of times we query the Github API. Once more for bump-cask-pr and once more for brew bump. We could consider grabbing everything from the Github API and then splitting it into open and closed PRs in brew bump which would save an API request. The difference is that I think we would end up grabbing all of them meaning most of the data wouldn't be relevant to us (really old closed PRs). I'm not sure it's worth the effort (and I'm lazy).

bump

It now checks for the closed PRs unless the user doesn't want us to hit the Github API (--no-pull-requests) or we've already found a matching open PR or a new version of the package isn't available.

No matching PRs

$ brew bump insomnia
==> insomnia is up to date!
Current cask version   :  2022.7.5
Latest livecheck version: 2022.7.5
Latest Repology version:  2022.7.5
Open pull requests:       none
Closed pull requests:     none

Matching open PR

$ brew bump --cask media-center
==> media-center
Current cask version   :  30.00.41
Latest livecheck version: 30.00.41
Latest Repology version:  present only in Homebrew
Open pull requests:       Update media-center from 30.00.41 to 30.00.45 (https://github.com/Homebrew/homebrew-cask/pull/139744)
Closed pull requests:     none

Matching closed PR

/u/l/Homebrew (add-closed-pr-check-to-bump-cmds|✚1) $ brew bump ott
==> ott
Current formula version:  0.32
Latest livecheck version: 0.33
Latest Repology version:  0.32
Open pull requests:       none
Closed pull requests:     ott 0.33 (https://github.com/Homebrew/homebrew-core/pull/120748)

bump-cask-pr

It checks for closed PRs matching the version specified after checking for open ones.

Matching open PR

$ brew bump-cask-pr -n media-center --version=30.00.45
Error: These open pull requests may be duplicates:
Update media-center from 30.00.41 to 30.00.45 https://github.com/Homebrew/homebrew-cask/pull/139744
Duplicate PRs should not be opened. Use --force to override this error.

Matching closed PR

$ brew bump-cask-pr -n insomnia --version=2022.7.5
Error: These closed pull requests may be duplicates:
Update insomnia from 2022.7.4 to 2022.7.5 https://github.com/Homebrew/homebrew-cask/pull/139787
Duplicate PRs should not be opened. Use --force to override this error.

Currently we only check for closed PRs in
`bump-cask-pr`. This adds that check to `bump`
and `bump-formula-pr`. The idea is that this
check can warn users about already updated
packages or those that can't be updated
easily and should be updated manually instead.
@BrewTestBot
Copy link
Member

Review period will end on 2023-01-24 at 00:00:00 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Jan 21, 2023
@@ -26,7 +26,7 @@ def bump_args
switch "--cask", "--casks",
description: "Check only casks."
switch "--open-pr",
description: "Open a pull request for the new version if there are none already open."
description: "Open a pull request for the new version if none have been opened yet."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is my attempt at clarifying that matching open or closed PRs will block you from opening another one. It's still probably too subtle though.

@@ -511,7 +511,7 @@ def check_for_duplicate_pull_requests(name, tap_remote_repo, state:, file:, args
return if pull_requests.blank?

duplicates_message = <<~EOS
These pull requests may be duplicates:
These #{state} pull requests may be duplicates:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just nice to have.

@apainintheneck apainintheneck marked this pull request as ready for review January 21, 2023 03:58
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.

Very nice! Great work as usual @apainintheneck!

@MikeMcQuaid MikeMcQuaid added the critical Critical change which should be shipped as soon as possible. label Jan 23, 2023
@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Jan 23, 2023
@BrewTestBot
Copy link
Member

Review period skipped due to critical label.

@MikeMcQuaid MikeMcQuaid merged commit 3be12ca into Homebrew:master Jan 23, 2023
@github-actions github-actions bot added the outdated PR was locked due to age label Feb 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 23, 2023
@apainintheneck apainintheneck deleted the add-closed-pr-check-to-bump-cmds branch March 24, 2023 03:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
critical Critical change which should be shipped as soon as possible. outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

brew bump is giving invalid suggestion
3 participants