From 45c61cdcdbe182d2ed2d8deb8dab2b3ab2507095 Mon Sep 17 00:00:00 2001 From: Michka Popoff Date: Mon, 25 Feb 2019 22:56:29 +0100 Subject: [PATCH] pull: fix tap name for linuxbrew --- Library/Homebrew/dev-cmd/pull.rb | 4 ++-- Library/Homebrew/tap.rb | 2 +- Library/Homebrew/tap_constants.rb | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index 41c67a4026..e2ea383132 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -109,10 +109,10 @@ module Homebrew elsif (api_match = arg.match HOMEBREW_PULL_API_REGEX) _, user, repo, issue = *api_match url = "https://github.com/#{user}/#{repo}/pull/#{issue}" - tap = Tap.fetch(user, repo) if repo.start_with?("homebrew-") + tap = Tap.fetch(user, repo) if repo.match?(HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX) elsif (url_match = arg.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX) url, user, repo, issue = *url_match - tap = Tap.fetch(user, repo) if repo.start_with?("homebrew-") + tap = Tap.fetch(user, repo) if repo.match?(HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX) else odie "Not a GitHub pull request or commit: #{arg}" end diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 3e039897cf..c28b9775eb 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -26,7 +26,7 @@ class Tap # We special case homebrew and linuxbrew so that users don't have to shift in a terminal. user = user.capitalize if ["homebrew", "linuxbrew"].include? user - repo = repo.delete_prefix "homebrew-" + repo = repo.sub(HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX, "") return CoreTap.instance if ["Homebrew", "Linuxbrew"].include?(user) && ["core", "homebrew"].include?(repo) diff --git a/Library/Homebrew/tap_constants.rb b/Library/Homebrew/tap_constants.rb index 749f36ca7a..764c547705 100644 --- a/Library/Homebrew/tap_constants.rb +++ b/Library/Homebrew/tap_constants.rb @@ -8,3 +8,4 @@ HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY)}/Taps/(?[\w- HOMEBREW_TAP_PATH_REGEX = Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{(?:/.*)?$}.source) # match official taps' casks, e.g. homebrew/cask/somecask or homebrew/cask-versions/somecask HOMEBREW_CASK_TAP_CASK_REGEX = %r{^(?:([Cc]askroom)/(cask|versions)|(homebrew)/(cask|cask-[\w-]+))/([\w+-.]+)$}.freeze +HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX = /^(home|linux)brew-/.freeze