Merge pull request #16274 from Bo98/bump-cask-pr-dup-check-fix

bump-cask-pr: fix duplicate PR checking with comma versions
This commit is contained in:
Mike McQuaid 2023-11-30 11:52:15 +00:00 committed by GitHub
commit 395ea6b261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -139,11 +139,7 @@ module Homebrew
# For simplicity, our naming defers to the arm version if we multiple architectures are specified # For simplicity, our naming defers to the arm version if we multiple architectures are specified
branch_version = new_version.arm || new_version.general branch_version = new_version.arm || new_version.general
if branch_version.is_a?(Cask::DSL::Version) if branch_version.is_a?(Cask::DSL::Version)
commit_version = if branch_version.before_comma == cask.version.before_comma commit_version = shortened_version(branch_version, cask: cask)
branch_version
else
branch_version.before_comma
end
branch_name = "bump-#{cask.token}-#{branch_version.tr(",:", "-")}" branch_name = "bump-#{cask.token}-#{branch_version.tr(",:", "-")}"
commit_message ||= "#{cask.token} #{commit_version}" commit_message ||= "#{cask.token} #{commit_version}"
end end
@ -174,6 +170,15 @@ module Homebrew
GitHub.create_bump_pr(pr_info, args: args) GitHub.create_bump_pr(pr_info, args: args)
end 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
version
else
version.before_comma
end
end
sig { sig {
params( params(
cask: Cask::Cask, cask: Cask::Cask,
@ -257,7 +262,7 @@ module Homebrew
cask.token, cask.token,
tap_remote_repo, tap_remote_repo,
state: "closed", state: "closed",
version: version, version: shortened_version(version, cask: cask),
file: cask.sourcefile_path.relative_path_from(cask.tap.path).to_s, file: cask.sourcefile_path.relative_path_from(cask.tap.path).to_s,
args: args, args: args,
) )