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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions Library/Homebrew/dev-cmd/bump-cask-pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,7 @@
# For simplicity, our naming defers to the arm version if we multiple architectures are specified
branch_version = new_version.arm || new_version.general
if branch_version.is_a?(Cask::DSL::Version)
commit_version = if branch_version.before_comma == cask.version.before_comma
branch_version
else
branch_version.before_comma
end
commit_version = shortened_version(branch_version, cask: cask)
branch_name = "bump-#{cask.token}-#{branch_version.tr(",:", "-")}"
commit_message ||= "#{cask.token} #{commit_version}"
end
Expand Down Expand Up @@ -174,6 +170,15 @@
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

Check warning on line 175 in Library/Homebrew/dev-cmd/bump-cask-pr.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bump-cask-pr.rb#L175

Added line #L175 was not covered by tests
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.

version
else
version.before_comma
end
end

sig {
params(
cask: Cask::Cask,
Expand Down Expand Up @@ -260,7 +265,7 @@
cask.token,
tap_remote_repo,
state: "closed",
version: version,
version: shortened_version(version, cask: cask),
file: cask.sourcefile_path.relative_path_from(cask.tap.path).to_s,
args: args,
)
Expand Down