From 96cbce015e0b327bd7d30fc101cbd25452cd2fd8 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Fri, 17 Jun 2016 08:17:56 -0700 Subject: [PATCH] bump-formula-pr: remove formula revision If we're bumping the formula's stable version, then we also must reset the formula revision to zero. Note that if and only if a revision is being removed, this commit will enforce the convention that there should be a blank line before a simple head spec if and only if there is a formula revision. Any preexisting violation of the convention (in particular, a blank line before a simple head spec in the absence of a formula revision) won't be proactively corrected since we'd not be removing a formula revision in that case. Closes #369. Signed-off-by: ilovezfs --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index c4aef20b2b..10df65860c 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -20,7 +20,9 @@ module Homebrew contents = path.open("r") { |f| Formulary.set_encoding(f).read } contents.extend(StringInreplaceExtension) replacement_pairs.each do |old, new| - ohai "replace \"#{old}\" with \"#{new}\"" unless ARGV.flag?("--quiet") + unless ARGV.flag?("--quiet") + ohai "replace #{old.inspect} with #{new.inspect}" + end contents.gsub!(old, new) end if contents.errors.any? @@ -30,7 +32,9 @@ module Homebrew else Utils::Inreplace.inreplace(path) do |s| replacement_pairs.each do |old, new| - ohai "replace \"#{old}\" with \"#{new}\"" unless ARGV.flag?("--quiet") + unless ARGV.flag?("--quiet") + ohai "replace #{old.inspect} with #{new.inspect}" + end s.gsub!(old, new) end end @@ -86,7 +90,12 @@ module Homebrew old_formula_version = formula_version(formula, requested_spec) - replacement_pairs = if new_url_hash + replacement_pairs = [] + if requested_spec == :stable && formula.revision != 0 + replacement_pairs << [/^ revision \d+\n(\n( head "))?/m, "\\2"] + end + + replacement_pairs += if new_url_hash [ [formula_spec.url, new_url], [old_hash, new_hash],