Merge pull request #9030 from MikeMcQuaid/gpg-tweaks
Unify and use Git username/email/GPG handling.
This commit is contained in:
commit
05bbb41022
@ -549,6 +549,7 @@ module Homebrew
|
||||
|
||||
unless args.no_commit?
|
||||
Utils::Git.set_name_email!
|
||||
Utils::Git.setup_gpg!
|
||||
|
||||
short_name = formula_name.split("/", -1).last
|
||||
pkg_version = bottle_hash["formula"]["pkg_version"]
|
||||
|
||||
@ -64,27 +64,6 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
def setup_git_environment!
|
||||
# Passthrough Git environment variables
|
||||
ENV["GIT_COMMITTER_NAME"] = ENV["HOMEBREW_GIT_NAME"] if ENV["HOMEBREW_GIT_NAME"]
|
||||
ENV["GIT_COMMITTER_EMAIL"] = ENV["HOMEBREW_GIT_EMAIL"] if ENV["HOMEBREW_GIT_EMAIL"]
|
||||
|
||||
# Depending on user configuration, git may try to invoke gpg.
|
||||
return unless Utils.popen_read("git config --get --bool commit.gpgsign").chomp == "true"
|
||||
|
||||
begin
|
||||
gnupg = Formula["gnupg"]
|
||||
rescue FormulaUnavailableError
|
||||
nil
|
||||
else
|
||||
if gnupg.any_version_installed?
|
||||
path = PATH.new(ENV.fetch("PATH"))
|
||||
path.prepend(gnupg.any_installed_prefix/"bin")
|
||||
ENV["PATH"] = path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Separates a commit message into subject, body, and trailers.
|
||||
def separate_commit_message(message)
|
||||
subject = message.lines.first.strip
|
||||
@ -375,7 +354,8 @@ module Homebrew
|
||||
mirror_repo = args.bintray_mirror || "mirror"
|
||||
tap = Tap.fetch(args.tap || CoreTap.instance.name)
|
||||
|
||||
setup_git_environment!
|
||||
Utils::Git.set_name_email!
|
||||
Utils::Git.setup_gpg!
|
||||
|
||||
args.named.uniq.each do |arg|
|
||||
arg = "#{tap.default_remote}/pull/#{arg}" if arg.to_i.positive?
|
||||
|
||||
@ -35,10 +35,8 @@ module Homebrew
|
||||
ohai "git add vendor/bundle"
|
||||
system "git", "add", "vendor/bundle"
|
||||
|
||||
if Formula["gpg"].optlinked?
|
||||
ENV["PATH"] = PATH.new(ENV["PATH"])
|
||||
.prepend(Formula["gpg"].opt_bin)
|
||||
end
|
||||
Utils::Git.set_name_email!
|
||||
Utils::Git.setup_gpg!
|
||||
|
||||
ohai "git commit"
|
||||
system "git", "commit", "--message", "brew vendor-gems: commit updates."
|
||||
|
||||
@ -126,6 +126,13 @@ module Utils
|
||||
ENV["GIT_COMMITTER_EMAIL"] = Homebrew::EnvConfig.git_email if committer
|
||||
end
|
||||
|
||||
def setup_gpg!
|
||||
return unless Formula["gnupg"].optlinked?
|
||||
|
||||
ENV["PATH"] = PATH.new(ENV["PATH"])
|
||||
.prepend(Formula["gnupg"].opt_bin)
|
||||
end
|
||||
|
||||
def origin_branch(repo)
|
||||
Utils.popen_read(git, "-C", repo, "symbolic-ref", "-q", "--short",
|
||||
"refs/remotes/origin/HEAD").chomp.presence
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user