dev-cmd/bump-formula-pr: always use full git repo as tap remote

This commit is contained in:
Dawid Dziurla 2024-10-15 10:20:58 +02:00
parent 58b03edb94
commit 02cef968a2
No known key found for this signature in database
GPG Key ID: 7B6D8368172E9B0B
3 changed files with 8 additions and 4 deletions

View File

@ -129,7 +129,7 @@ module Homebrew
# spamming during normal output. # spamming during normal output.
Homebrew.install_bundler_gems!(groups: ["audit", "style"]) unless args.no_audit? Homebrew.install_bundler_gems!(groups: ["audit", "style"]) unless args.no_audit?
tap_remote_repo = formula.tap.full_name || formula.tap.remote_repository tap_remote_repo = formula.tap.remote_repository
remote = "origin" remote = "origin"
remote_branch = formula.tap.git_repository.origin_branch_name remote_branch = formula.tap.git_repository.origin_branch_name
previous_branch = "-" previous_branch = "-"

View File

@ -275,10 +275,9 @@ class Tap
sig { returns(T.nilable(String)) } sig { returns(T.nilable(String)) }
def remote_repository def remote_repository
return unless (remote = self.remote) return unless (remote = self.remote)
return unless (match = remote.match(HOMEBREW_TAP_REPOSITORY_REGEX))
@remote_repository ||= remote.delete_prefix("https://github.com/") @remote_repository ||= T.must(match[:remote_repository])
.delete_prefix("git@github.com:")
.delete_suffix(".git")
end end
# @deprecated # @deprecated

View File

@ -13,6 +13,11 @@ HOMEBREW_DEFAULT_TAP_FORMULA_REGEX = T.let(
%r{\A(?:[Hh]omebrew/(?:homebrew-)?core/)?(?<name>#{HOMEBREW_TAP_FORMULA_NAME_REGEX.source})\Z}, %r{\A(?:[Hh]omebrew/(?:homebrew-)?core/)?(?<name>#{HOMEBREW_TAP_FORMULA_NAME_REGEX.source})\Z},
Regexp, Regexp,
) )
# Match taps' remote repository, e.g. `someuser/somerepo`.
HOMEBREW_TAP_REPOSITORY_REGEX = T.let(
%r{\A.+[/:](?<remote_repository>[^/:]+/[^/:]+?(?=\.git/*\Z|/*\Z))},
Regexp,
)
# Match a cask token. # Match a cask token.
HOMEBREW_TAP_CASK_TOKEN_REGEX = T.let(/(?<token>[\w+\-.@]+)/, Regexp) HOMEBREW_TAP_CASK_TOKEN_REGEX = T.let(/(?<token>[\w+\-.@]+)/, Regexp)