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