From 99bb068ca734c7096bf82c72730f1babc7f72431 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Wed, 24 Jan 2018 06:37:27 -0800 Subject: [PATCH] bump-formula-pr: improve formula name guessing. --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 7069a48167..334269a0ae 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -137,9 +137,16 @@ module Homebrew new_url = ARGV.value("url") if new_url && !formula - is_devel = ARGV.include?("--devel") - base_url = new_url.split("/")[0..4].join("/") + # Split the new URL on / and find any formulae that have the same URL + # except for the last component, but don't try to match any more than the + # first five components since sometimes the last component isn't the only + # one to change. + new_url_split = new_url.split("/") + maximum_url_components_to_match = 5 + components_to_match = [new_url_split.count - 1, maximum_url_components_to_match].min + base_url = new_url_split.first(components_to_match).join("/") base_url = /#{Regexp.escape(base_url)}/ + is_devel = ARGV.include?("--devel") guesses = [] Formula.each do |f| if is_devel && f.devel && f.devel.url && f.devel.url.match(base_url)