mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Allow specifying committer for some dev-cmd
s
This commit is contained in:
parent
c7e183ef9f
commit
53a7065bcc
@ -73,6 +73,8 @@ module Homebrew
|
|||||||
switch "--only-json-tab",
|
switch "--only-json-tab",
|
||||||
depends_on: "--json",
|
depends_on: "--json",
|
||||||
description: "When passed with `--json`, the tab will be written to the JSON file but not the bottle."
|
description: "When passed with `--json`, the tab will be written to the JSON file but not the bottle."
|
||||||
|
flag "--committer=",
|
||||||
|
description: "Specify a committer name and email in `git`'s standard author format."
|
||||||
flag "--root-url=",
|
flag "--root-url=",
|
||||||
description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default."
|
description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default."
|
||||||
|
|
||||||
@ -619,9 +621,15 @@ module Homebrew
|
|||||||
path.atomic_write(formula_ast.process)
|
path.atomic_write(formula_ast.process)
|
||||||
|
|
||||||
unless args.no_commit?
|
unless args.no_commit?
|
||||||
Utils::Git.set_name_email!
|
Utils::Git.set_name_email!(committer: args.committer.blank?)
|
||||||
Utils::Git.setup_gpg!
|
Utils::Git.setup_gpg!
|
||||||
|
|
||||||
|
if (committer = args.committer)
|
||||||
|
committer = Utils.parse_author!(committer)
|
||||||
|
ENV["GIT_COMMITTER_NAME"] = committer[:name]
|
||||||
|
ENV["GIT_COMMITTER_EMAIL"] = committer[:email]
|
||||||
|
end
|
||||||
|
|
||||||
short_name = formula_name.split("/", -1).last
|
short_name = formula_name.split("/", -1).last
|
||||||
pkg_version = bottle_hash["formula"]["pkg_version"]
|
pkg_version = bottle_hash["formula"]["pkg_version"]
|
||||||
|
|
||||||
|
@ -44,6 +44,8 @@ module Homebrew
|
|||||||
switch "--warn-on-upload-failure",
|
switch "--warn-on-upload-failure",
|
||||||
description: "Warn instead of raising an error if the bottle upload fails. "\
|
description: "Warn instead of raising an error if the bottle upload fails. "\
|
||||||
"Useful for repairing bottle uploads that previously failed."
|
"Useful for repairing bottle uploads that previously failed."
|
||||||
|
flag "--committer=",
|
||||||
|
description: "Specify a committer name and email in `git`'s standard author format."
|
||||||
flag "--message=",
|
flag "--message=",
|
||||||
depends_on: "--autosquash",
|
depends_on: "--autosquash",
|
||||||
description: "Message to include when autosquashing revision bumps, deletions, and rebuilds."
|
description: "Message to include when autosquashing revision bumps, deletions, and rebuilds."
|
||||||
@ -365,9 +367,15 @@ module Homebrew
|
|||||||
mirror_repo = args.bintray_mirror || "mirror"
|
mirror_repo = args.bintray_mirror || "mirror"
|
||||||
tap = Tap.fetch(args.tap || CoreTap.instance.name)
|
tap = Tap.fetch(args.tap || CoreTap.instance.name)
|
||||||
|
|
||||||
Utils::Git.set_name_email!
|
Utils::Git.set_name_email!(committer: args.committer.blank?)
|
||||||
Utils::Git.setup_gpg!
|
Utils::Git.setup_gpg!
|
||||||
|
|
||||||
|
if (committer = args.committer)
|
||||||
|
committer = Utils.parse_author!(committer)
|
||||||
|
ENV["GIT_COMMITTER_NAME"] = committer[:name]
|
||||||
|
ENV["GIT_COMMITTER_EMAIL"] = committer[:email]
|
||||||
|
end
|
||||||
|
|
||||||
args.named.uniq.each do |arg|
|
args.named.uniq.each do |arg|
|
||||||
arg = "#{tap.default_remote}/pull/#{arg}" if arg.to_i.positive?
|
arg = "#{tap.default_remote}/pull/#{arg}" if arg.to_i.positive?
|
||||||
url_match = arg.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX
|
url_match = arg.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX
|
||||||
|
@ -30,6 +30,8 @@ module Homebrew
|
|||||||
switch "--warn-on-upload-failure",
|
switch "--warn-on-upload-failure",
|
||||||
description: "Warn instead of raising an error if the bottle upload fails. "\
|
description: "Warn instead of raising an error if the bottle upload fails. "\
|
||||||
"Useful for repairing bottle uploads that previously failed."
|
"Useful for repairing bottle uploads that previously failed."
|
||||||
|
flag "--committer=",
|
||||||
|
description: "Specify a committer name and email in `git`'s standard author format."
|
||||||
flag "--archive-item=",
|
flag "--archive-item=",
|
||||||
description: "Upload to the specified Internet Archive item (default: `homebrew`)."
|
description: "Upload to the specified Internet Archive item (default: `homebrew`)."
|
||||||
flag "--bintray-org=",
|
flag "--bintray-org=",
|
||||||
@ -103,6 +105,7 @@ module Homebrew
|
|||||||
bottle_args << "--debug" if args.debug?
|
bottle_args << "--debug" if args.debug?
|
||||||
bottle_args << "--keep-old" if args.keep_old?
|
bottle_args << "--keep-old" if args.keep_old?
|
||||||
bottle_args << "--root-url=#{args.root_url}" if args.root_url
|
bottle_args << "--root-url=#{args.root_url}" if args.root_url
|
||||||
|
bottle_args << "--committer='#{args.committer}'" if args.committer
|
||||||
bottle_args << "--no-commit" if args.no_commit?
|
bottle_args << "--no-commit" if args.no_commit?
|
||||||
bottle_args += json_files
|
bottle_args += json_files
|
||||||
|
|
||||||
|
@ -210,6 +210,19 @@ describe "globally-scoped helper methods" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
specify "#parse_author!" do
|
||||||
|
parse_error_msg = /Unable to parse name and email/
|
||||||
|
|
||||||
|
expect(parse_author!("John Doe <john.doe@example.com>"))
|
||||||
|
.to eq({ name: "John Doe", email: "john.doe@example.com" })
|
||||||
|
expect { parse_author!("") }
|
||||||
|
.to raise_error(parse_error_msg)
|
||||||
|
expect { parse_author!("John Doe") }
|
||||||
|
.to raise_error(parse_error_msg)
|
||||||
|
expect { parse_author!("<john.doe@example.com>") }
|
||||||
|
.to raise_error(parse_error_msg)
|
||||||
|
end
|
||||||
|
|
||||||
specify "#disk_usage_readable" do
|
specify "#disk_usage_readable" do
|
||||||
expect(disk_usage_readable(1)).to eq("1B")
|
expect(disk_usage_readable(1)).to eq("1B")
|
||||||
expect(disk_usage_readable(1000)).to eq("1000B")
|
expect(disk_usage_readable(1000)).to eq("1000B")
|
||||||
|
@ -467,6 +467,13 @@ module Kernel
|
|||||||
end.uniq.compact
|
end.uniq.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def parse_author!(author)
|
||||||
|
/^(?<name>[^<]+?)[ \t]*<(?<email>[^>]+?)>$/ =~ author
|
||||||
|
raise "Unable to parse name and email." if name.blank? && email.blank?
|
||||||
|
|
||||||
|
{ name: name, email: email }
|
||||||
|
end
|
||||||
|
|
||||||
def disk_usage_readable(size_in_bytes)
|
def disk_usage_readable(size_in_bytes)
|
||||||
if size_in_bytes >= 1_073_741_824
|
if size_in_bytes >= 1_073_741_824
|
||||||
size = size_in_bytes.to_f / 1_073_741_824
|
size = size_in_bytes.to_f / 1_073_741_824
|
||||||
|
Loading…
x
Reference in New Issue
Block a user