From 283ff9e3adef34fb8d53063fbd5a3f2e3ac64c92 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Fri, 24 Jun 2022 19:20:21 -0400 Subject: [PATCH] bump-formula-pr: handle url with specs hash The existing `bump-formula-pr` regexes expect a `url` string to only be followed by a newline. However, `url` also accepts a `specs` hash, which can appear after the `url` string. For example: ``` url "https://www.example.com/1.2.3.tar.gz", using: :homebrew_curl ``` This commit modifies the regexes to capture anything after the `url` string and before the newline. This works for the aforementioned example, where the trailing hash is on the same line, but it won't work if the hash appears on a subsequent line. For example: ``` url "https://www.example.com/1.2.3.tar.gz", using: :homebrew_curl ``` --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index df48b5905d..a731b83be1 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -275,7 +275,7 @@ module Homebrew if new_mirrors.present? replacement_pairs << [ - /^( +)(url "#{Regexp.escape(new_url)}"\n)/m, + /^( +)(url "#{Regexp.escape(new_url)}"[^\n]*?\n)/m, "\\1\\2\\1mirror \"#{new_mirrors.join("\"\n\\1mirror \"")}\"\n", ] end @@ -293,7 +293,7 @@ module Homebrew ] elsif new_url.present? [ - /^( +)(url "#{Regexp.escape(new_url)}"\n)/m, + /^( +)(url "#{Regexp.escape(new_url)}"[^\n]*?\n)/m, "\\1\\2\\1version \"#{new_version}\"\n", ] elsif new_revision.present?