bump-revision: allow multiple formulae to be specified
This commit is contained in:
parent
7d78949479
commit
36f3e09669
@ -9,7 +9,7 @@ module Homebrew
|
||||
def bump_revision_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
usage_banner <<~EOS
|
||||
`bump-revision` [<options>] <formula>
|
||||
`bump-revision` [<options>] <formula> [<formula> ...]
|
||||
|
||||
Create a commit to increment the revision of <formula>. If no revision is
|
||||
present, "revision 1" will be added.
|
||||
@ -19,7 +19,7 @@ module Homebrew
|
||||
flag "--message=",
|
||||
description: "Append <message> to the default commit message."
|
||||
|
||||
named :formula
|
||||
min_named :formula
|
||||
end
|
||||
end
|
||||
|
||||
@ -30,63 +30,64 @@ module Homebrew
|
||||
# user path, too.
|
||||
ENV["PATH"] = ENV["HOMEBREW_PATH"]
|
||||
|
||||
formula = args.formulae.first
|
||||
current_revision = formula.revision
|
||||
args.formulae.each do |formula|
|
||||
current_revision = formula.revision
|
||||
|
||||
if current_revision.zero?
|
||||
formula_spec = formula.stable
|
||||
hash_type, old_hash = if (checksum = formula_spec.checksum)
|
||||
[checksum.hash_type, checksum.hexdigest]
|
||||
end
|
||||
|
||||
old = if formula.license
|
||||
license_string = if formula.license.length > 1
|
||||
formula.license
|
||||
else
|
||||
"\"#{formula.license.first}\""
|
||||
if current_revision.zero?
|
||||
formula_spec = formula.stable
|
||||
hash_type, old_hash = if (checksum = formula_spec.checksum)
|
||||
[checksum.hash_type, checksum.hexdigest]
|
||||
end
|
||||
# insert replacement revision after license
|
||||
<<~EOS
|
||||
license #{license_string}
|
||||
EOS
|
||||
elsif formula.path.read.include?("stable do\n")
|
||||
# insert replacement revision after homepage
|
||||
<<~EOS
|
||||
homepage "#{formula.homepage}"
|
||||
EOS
|
||||
elsif hash_type
|
||||
# insert replacement revision after hash
|
||||
<<~EOS
|
||||
#{hash_type} "#{old_hash}"
|
||||
EOS
|
||||
|
||||
old = if formula.license
|
||||
license_string = if formula.license.length > 1
|
||||
formula.license
|
||||
else
|
||||
"\"#{formula.license.first}\""
|
||||
end
|
||||
# insert replacement revision after license
|
||||
<<~EOS
|
||||
license #{license_string}
|
||||
EOS
|
||||
elsif formula.path.read.include?("stable do\n")
|
||||
# insert replacement revision after homepage
|
||||
<<~EOS
|
||||
homepage "#{formula.homepage}"
|
||||
EOS
|
||||
elsif hash_type
|
||||
# insert replacement revision after hash
|
||||
<<~EOS
|
||||
#{hash_type} "#{old_hash}"
|
||||
EOS
|
||||
else
|
||||
# insert replacement revision after :revision
|
||||
<<~EOS
|
||||
revision: "#{formula_spec.specs[:revision]}"
|
||||
EOS
|
||||
end
|
||||
replacement = old + " revision 1\n"
|
||||
|
||||
else
|
||||
# insert replacement revision after :revision
|
||||
<<~EOS
|
||||
revision: "#{formula_spec.specs[:revision]}"
|
||||
EOS
|
||||
old = "revision #{current_revision}"
|
||||
replacement = "revision #{current_revision+1}"
|
||||
end
|
||||
replacement = old + " revision 1\n"
|
||||
|
||||
else
|
||||
old = "revision #{current_revision}"
|
||||
replacement = "revision #{current_revision+1}"
|
||||
end
|
||||
|
||||
if args.dry_run?
|
||||
ohai "replace #{old.inspect} with #{replacement.inspect}" unless args.quiet?
|
||||
else
|
||||
Utils::Inreplace.inreplace(formula.path) do |s|
|
||||
s.gsub!(old, replacement)
|
||||
if args.dry_run?
|
||||
ohai "replace #{old.inspect} with #{replacement.inspect}" unless args.quiet?
|
||||
else
|
||||
Utils::Inreplace.inreplace(formula.path) do |s|
|
||||
s.gsub!(old, replacement)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
message = "#{formula.name}: revision bump #{args.message}"
|
||||
if args.dry_run?
|
||||
ohai "git commit --no-edit --verbose --message=#{message} -- #{formula.path}"
|
||||
else
|
||||
formula.path.parent.cd do
|
||||
safe_system "git", "commit", "--no-edit", "--verbose",
|
||||
"--message=#{message}", "--", formula.path
|
||||
message = "#{formula.name}: revision bump #{args.message}"
|
||||
if args.dry_run?
|
||||
ohai "git commit --no-edit --verbose --message=#{message} -- #{formula.path}"
|
||||
else
|
||||
formula.path.parent.cd do
|
||||
safe_system "git", "commit", "--no-edit", "--verbose",
|
||||
"--message=#{message}", "--", formula.path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -865,7 +865,7 @@ nor vice versa. It must use whichever style specification the formula already us
|
||||
* `-f`, `--force`:
|
||||
Ignore duplicate open PRs. Remove all mirrors if --mirror= was not specified.
|
||||
|
||||
### `bump-revision` [*`options`*] *`formula`*
|
||||
### `bump-revision` [*`options`*] *`formula`* [*`formula`* ...]
|
||||
|
||||
Create a commit to increment the revision of *`formula`*. If no revision is
|
||||
present, "revision 1" will be added.
|
||||
|
@ -1210,7 +1210,7 @@ Specify the new git commit \fIrevision\fR corresponding to the specified \fItag\
|
||||
\fB\-f\fR, \fB\-\-force\fR
|
||||
Ignore duplicate open PRs\. Remove all mirrors if \-\-mirror= was not specified\.
|
||||
.
|
||||
.SS "\fBbump\-revision\fR [\fIoptions\fR] \fIformula\fR"
|
||||
.SS "\fBbump\-revision\fR [\fIoptions\fR] \fIformula\fR [\fIformula\fR \.\.\.]"
|
||||
Create a commit to increment the revision of \fIformula\fR\. If no revision is present, "revision 1" will be added\.
|
||||
.
|
||||
.TP
|
||||
|
Loading…
x
Reference in New Issue
Block a user