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
```
This commit is contained in:
Sam Ford 2022-06-24 19:20:21 -04:00
parent f1d04b4c3d
commit 283ff9e3ad
No known key found for this signature in database
GPG Key ID: 7AF5CBEE1DD6F76D

View File

@ -275,7 +275,7 @@ module Homebrew
if new_mirrors.present? if new_mirrors.present?
replacement_pairs << [ 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", "\\1\\2\\1mirror \"#{new_mirrors.join("\"\n\\1mirror \"")}\"\n",
] ]
end end
@ -293,7 +293,7 @@ module Homebrew
] ]
elsif new_url.present? 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", "\\1\\2\\1version \"#{new_version}\"\n",
] ]
elsif new_revision.present? elsif new_revision.present?