bump-formula-pr: handle additional edge cases
This commit is contained in:
parent
2c77a540b5
commit
59cfef6db0
@ -70,8 +70,8 @@ module Homebrew
|
|||||||
flag "--tag=",
|
flag "--tag=",
|
||||||
description: "Specify the new git commit <tag> for the formula."
|
description: "Specify the new git commit <tag> for the formula."
|
||||||
flag "--revision=",
|
flag "--revision=",
|
||||||
depends_on: "--tag=",
|
description: "Specify the new commit <revision> corresponding to the specified git <tag> "\
|
||||||
description: "Specify the new git commit <revision> corresponding to the specified <tag>."
|
"or specified <version>."
|
||||||
switch "-f", "--force",
|
switch "-f", "--force",
|
||||||
description: "Ignore duplicate open PRs. Remove all mirrors if `--mirror` was not specified."
|
description: "Ignore duplicate open PRs. Remove all mirrors if `--mirror` was not specified."
|
||||||
|
|
||||||
@ -121,6 +121,10 @@ module Homebrew
|
|||||||
def bump_formula_pr
|
def bump_formula_pr
|
||||||
args = bump_formula_pr_args.parse
|
args = bump_formula_pr_args.parse
|
||||||
|
|
||||||
|
if args.revision.present? && args.tag.nil? && args.version.nil?
|
||||||
|
raise UsageError, "`--revision` must be passed with either `--tag` or `--version`!"
|
||||||
|
end
|
||||||
|
|
||||||
# As this command is simplifying user-run commands then let's just use a
|
# As this command is simplifying user-run commands then let's just use a
|
||||||
# user path, too.
|
# user path, too.
|
||||||
ENV["PATH"] = ENV["HOMEBREW_PATH"]
|
ENV["PATH"] = ENV["HOMEBREW_PATH"]
|
||||||
@ -177,21 +181,28 @@ module Homebrew
|
|||||||
check_closed_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag, args: args) unless new_version
|
check_closed_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag, args: args) unless new_version
|
||||||
false
|
false
|
||||||
elsif !hash_type
|
elsif !hash_type
|
||||||
odie "#{formula}: no --tag= or --version= argument specified!" if !new_tag && !new_version
|
if !new_tag && !new_version && !new_revision
|
||||||
new_tag ||= old_tag.gsub(old_version, new_version)
|
raise UsageError, "#{formula}: no --tag= or --version= argument specified!"
|
||||||
if new_tag == old_tag
|
end
|
||||||
odie <<~EOS
|
|
||||||
You need to bump this formula manually since the new tag
|
if old_tag
|
||||||
and old tag are both #{new_tag}.
|
new_tag ||= old_tag.gsub(old_version, new_version)
|
||||||
EOS
|
if new_tag == old_tag
|
||||||
|
odie <<~EOS
|
||||||
|
You need to bump this formula manually since the new tag
|
||||||
|
and old tag are both #{new_tag}.
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
check_closed_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag, args: args) unless new_version
|
||||||
|
resource_path, forced_version = fetch_resource(formula, new_version, old_url, tag: new_tag)
|
||||||
|
new_revision = Utils.popen_read("git -C \"#{resource_path}\" rev-parse -q --verify HEAD")
|
||||||
|
new_revision = new_revision.strip
|
||||||
|
else
|
||||||
|
odie "#{formula}: the current URL requires specifying a --revision= argument." unless new_revision
|
||||||
end
|
end
|
||||||
check_closed_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag, args: args) unless new_version
|
|
||||||
resource_path, forced_version = fetch_resource(formula, new_version, old_url, tag: new_tag)
|
|
||||||
new_revision = Utils.popen_read("git -C \"#{resource_path}\" rev-parse -q --verify HEAD")
|
|
||||||
new_revision = new_revision.strip
|
|
||||||
false
|
false
|
||||||
elsif !new_url && !new_version
|
elsif !new_url && !new_version
|
||||||
odie "#{formula}: no --url= or --version= argument specified!"
|
raise UsageError, "#{formula}: no --url= or --version= argument specified!"
|
||||||
else
|
else
|
||||||
new_url ||= PyPI.update_pypi_url(old_url, new_version)
|
new_url ||= PyPI.update_pypi_url(old_url, new_version)
|
||||||
unless new_url
|
unless new_url
|
||||||
@ -241,7 +252,7 @@ module Homebrew
|
|||||||
new_hash,
|
new_hash,
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
else
|
elsif new_tag
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
formula_spec.specs[:tag],
|
formula_spec.specs[:tag],
|
||||||
@ -252,6 +263,24 @@ module Homebrew
|
|||||||
new_revision,
|
new_revision,
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
elsif new_url
|
||||||
|
[
|
||||||
|
[
|
||||||
|
/#{Regexp.escape(formula_spec.url)}/,
|
||||||
|
new_url,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
formula_spec.specs[:revision],
|
||||||
|
new_revision,
|
||||||
|
],
|
||||||
|
]
|
||||||
|
else
|
||||||
|
[
|
||||||
|
[
|
||||||
|
formula_spec.specs[:revision],
|
||||||
|
new_revision,
|
||||||
|
],
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
old_contents = File.read(formula.path) unless args.dry_run?
|
old_contents = File.read(formula.path) unless args.dry_run?
|
||||||
@ -312,8 +341,8 @@ module Homebrew
|
|||||||
if new_formula_version < old_formula_version
|
if new_formula_version < old_formula_version
|
||||||
formula.path.atomic_write(old_contents) unless args.dry_run?
|
formula.path.atomic_write(old_contents) unless args.dry_run?
|
||||||
odie <<~EOS
|
odie <<~EOS
|
||||||
You need to bump this formula manually since changing the
|
You need to bump this formula manually since changing the version
|
||||||
version from #{old_formula_version} to #{new_formula_version} would be a downgrade.
|
from #{old_formula_version} to #{new_formula_version} would be a downgrade.
|
||||||
EOS
|
EOS
|
||||||
elsif new_formula_version == old_formula_version
|
elsif new_formula_version == old_formula_version
|
||||||
formula.path.atomic_write(old_contents) unless args.dry_run?
|
formula.path.atomic_write(old_contents) unless args.dry_run?
|
||||||
|
@ -889,7 +889,7 @@ nor vice versa. It must use whichever style specification the formula already us
|
|||||||
* `--tag`:
|
* `--tag`:
|
||||||
Specify the new git commit *`tag`* for the formula.
|
Specify the new git commit *`tag`* for the formula.
|
||||||
* `--revision`:
|
* `--revision`:
|
||||||
Specify the new git commit *`revision`* corresponding to the specified *`tag`*.
|
Specify the new commit *`revision`* corresponding to the specified git *`tag`* or specified *`version`*.
|
||||||
* `-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.
|
||||||
|
|
||||||
|
@ -1236,7 +1236,7 @@ Specify the new git commit \fItag\fR for the formula\.
|
|||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-revision\fR
|
\fB\-\-revision\fR
|
||||||
Specify the new git commit \fIrevision\fR corresponding to the specified \fItag\fR\.
|
Specify the new commit \fIrevision\fR corresponding to the specified git \fItag\fR or specified \fIversion\fR\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fB\-f\fR, \fB\-\-force\fR
|
\fB\-f\fR, \fB\-\-force\fR
|
||||||
|
Loading…
x
Reference in New Issue
Block a user