pr-pull: update for gpg environment and secrets

Co-Authored-By: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Jonathan Chang 2020-03-31 22:11:30 +11:00
parent 1147106134
commit cd56e8b03e

View File

@ -46,6 +46,27 @@ 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.installed?
path = PATH.new(ENV.fetch("PATH"))
path.prepend(gnupg.installed_prefix/"bin")
ENV["PATH"] = path
end
end
end
def signoff!(pr, path: ".", dry_run: false)
message = Utils.popen_read "git", "-C", path, "log", "-1", "--pretty=%B"
close_message = "Closes ##{pr}."
@ -98,18 +119,20 @@ module Homebrew
bintray_user = ENV["HOMEBREW_BINTRAY_USER"]
bintray_key = ENV["HOMEBREW_BINTRAY_KEY"]
ENV.clear_sensitive_environment!
bintray_org = args.bintray_org || "homebrew"
if bintray_user.blank? || bintray_key.blank?
odie "Missing HOMEBREW_BINTRAY_USER or HOMEBREW_BINTRAY_KEY variables!" if !args.dry_run? && !args.no_upload?
else
bintray = Bintray.new(user: bintray_user, key: bintray_key, org: args.bintray_org)
bintray = Bintray.new(user: bintray_user, key: bintray_key, org: bintray_org)
end
workflow = args.workflow || "tests.yml"
artifact = args.artifact || "bottles"
tap = Tap.fetch(args.tap || "homebrew/core")
setup_git_environment!
args.named.each do |arg|
arg = "#{tap.default_remote}/pull/#{arg}" if arg.to_i.positive?
url_match = arg.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX