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

bump-cask-pr: fix duplicate PR checking with comma versions #16274

Merged
merged 1 commit into from Nov 30, 2023

Conversation

Bo98
Copy link
Member

@Bo98 Bo98 commented Nov 30, 2023

Fixes #16271

@apainintheneck
Copy link
Contributor

Maybe I'm misunderstanding the fix here but it seems to still be missing the closed PRs for the example given in the issue.

$ brew bump-cask-pr --dry-run --version 8u392-b08  semeru-jdk8-open
Error: These closed pull requests may be duplicates:
semeru-jdk8-open 8u392-b08 https://github.com/Homebrew/homebrew-cask-versions/pull/18540
semeru-jdk8-open 8u392-b08 https://github.com/Homebrew/homebrew-cask-versions/pull/18524
semeru-jdk8-open 8u392-b08 https://github.com/Homebrew/homebrew-cask-versions/pull/18514
Duplicate PRs should not be opened. Use --force to override this error.
$ brew bump-cask-pr --dry-run --version 8u392-b08,openj9-0.41.0  semeru-jdk8-open
==> Downloading https://github.com/ibmruntimes/semeru8-binaries/releases/download/jdk8u392-b08_openj9-0.41.0/ibm-semeru-open-jdk_x64_mac_8u392b08_openj9-0.41.
Already downloaded: /Users/kevinrobell/Library/Caches/Homebrew/downloads/a73924189f4d419f4e7f48dd47ef7d130f34c3ac127d8cfbdd8b0f6f95a07499--ibm-semeru-open-jdk_x64_mac_8u392b08_openj9-0.41.0.pkg
==> replace /version\s+["']8u392\-b08,openj9\-0\.41\.0["']/m with "version \"8u392-b08,openj9-0.41.0\""
==> brew audit --cask --online semeru-jdk8-open
==> brew style --fix semeru-jdk8-open.rb
==> try to fork repository with GitHub API
==> git add /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-versions/Casks/semeru-jdk8-open.rb
==> git checkout --no-track -b bump-semeru-jdk8-open-8u392-b08-openj9-0.41.0 origin/master
==> git commit --no-edit --verbose --message='semeru-jdk8-open 8u392-b08,openj9-0.41.0' -- /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-versions/Ca
==> git push --set-upstream FORK_URL bump-semeru-jdk8-open-8u392-b08-openj9-0.41.0:bump-semeru-jdk8-open-8u392-b08-openj9-0.41.0
==> git checkout --quiet -
==> create pull request with GitHub API (base branch: master)

@@ -174,6 +170,15 @@ def bump_cask_pr
GitHub.create_bump_pr(pr_info, args: args)
end

sig { params(version: Cask::DSL::Version, cask: Cask::Cask).returns(Cask::DSL::Version) }
def shortened_version(version, cask:)
if version.before_comma == cask.version.before_comma
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if version.before_comma == cask.version.before_comma
if version.before_comma == cask.version

Copy link
Member Author

Choose a reason for hiding this comment

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

That doesn't sound like it would ever be equal unless you are removing the comma in the bump.

The fix here was simply to share the existing logic used to title the commit/PR with the search functionality. They were previously not aligned so the search would of course not find the differently titled PR.

Copy link
Member

Choose a reason for hiding this comment

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

I was seeing the same issue where it wasn't working now, but should moving forward as your comment below implies.

@Bo98
Copy link
Member Author

Bo98 commented Nov 30, 2023

Maybe I'm misunderstanding the fix here but it seems to still be missing the closed PRs for the example given in the issue.

You will need to reset the local state of your repo to before the PRs were merged to see the effect of the fix. That matches the state the duplicate PRs were created (otherwise they would be empty diffs).

Your example would probably fail on a non-dry-run from an empty commit. Maybe that particular scenario should be made more explicit to make it also fail on dry runs.

Copy link
Contributor

@apainintheneck apainintheneck left a comment

Choose a reason for hiding this comment

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

LGTM!

I was able to reproduce the expected behavior after reseting the cask versions repo back a few days.

$ brew bump-cask-pr --dry-run --version 8u392-b08,openj9-0.41.0  semeru-jdk8-open
Error: These closed pull requests may be duplicates:
semeru-jdk8-open 8u392-b08 https://github.com/Homebrew/homebrew-cask-versions/pull/18540
semeru-jdk8-open 8u392-b08 https://github.com/Homebrew/homebrew-cask-versions/pull/18524
semeru-jdk8-open 8u392-b08 https://github.com/Homebrew/homebrew-cask-versions/pull/18514
Duplicate PRs should not be opened. Use --force to override this error.

@apainintheneck
Copy link
Contributor

Your example would probably fail on a non-dry-run from an empty commit. Maybe that particular scenario should be made more explicit to make it also fail on dry runs.

That's another good point.

@MikeMcQuaid MikeMcQuaid merged commit 395ea6b into Homebrew:master Nov 30, 2023
27 checks passed
@MikeMcQuaid
Copy link
Member

Great work @Bo98!

@Bo98 Bo98 deleted the bump-cask-pr-dup-check-fix branch November 30, 2023 13:15
@github-actions github-actions bot added the outdated PR was locked due to age label Dec 31, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

brew bump-cask-pr is not correctly finding existing pull requests
4 participants