mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
bump-formula-pr: fix when no 'version' stanza in formula found
Without this fix, a command like: `brew bump-formula-pr --version=0.3.3 --tag=v0.3.3 --revision=... test-formula-git-revision` will fail because: ``` Error: no implicit conversion of nil into String /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/bump-formula-pr.rb:281:in `escape' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/bump-formula-pr.rb:281:in `bump_formula_pr' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:111:in `<main>' ``` Additionally, reject all `nil` replacement pairs by calling `compact` method.
This commit is contained in:
parent
ae58255773
commit
1e805e04f9
@ -276,11 +276,16 @@ module Homebrew
|
|||||||
/^( +)(mirror "#{Regexp.escape(new_mirrors.last)}"\n)/m,
|
/^( +)(mirror "#{Regexp.escape(new_mirrors.last)}"\n)/m,
|
||||||
"\\1\\2\\1version \"#{new_version}\"\n",
|
"\\1\\2\\1version \"#{new_version}\"\n",
|
||||||
]
|
]
|
||||||
else
|
elsif new_url
|
||||||
[
|
[
|
||||||
/^( +)(url "#{Regexp.escape(new_url)}"\n)/m,
|
/^( +)(url "#{Regexp.escape(new_url)}"\n)/m,
|
||||||
"\\1\\2\\1version \"#{new_version}\"\n",
|
"\\1\\2\\1version \"#{new_version}\"\n",
|
||||||
]
|
]
|
||||||
|
elsif new_revision
|
||||||
|
[
|
||||||
|
/^( {2})( +)(:revision => "#{new_revision}"\n)/m,
|
||||||
|
"\\1\\2\\3\\1version \"#{new_version}\"\n",
|
||||||
|
]
|
||||||
end
|
end
|
||||||
elsif forced_version && new_version == "0"
|
elsif forced_version && new_version == "0"
|
||||||
replacement_pairs << [
|
replacement_pairs << [
|
||||||
@ -288,7 +293,7 @@ module Homebrew
|
|||||||
"",
|
"",
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
new_contents = inreplace_pairs(formula.path, replacement_pairs.uniq)
|
new_contents = inreplace_pairs(formula.path, replacement_pairs.uniq.compact)
|
||||||
|
|
||||||
new_formula_version = formula_version(formula, requested_spec, new_contents)
|
new_formula_version = formula_version(formula, requested_spec, new_contents)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user