diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb index a3b3124e36f0f..8b458ebe06263 100644 --- a/Library/Homebrew/env_config.rb +++ b/Library/Homebrew/env_config.rb @@ -274,10 +274,18 @@ module EnvConfig description: "Use this username when accessing the GitHub Packages Registry (where bottles may be stored).", }, HOMEBREW_GIT_EMAIL: { - description: "Set the Git author and committer email to this value.", + description: "Set the Git author name and, if `HOMEBREW_GIT_COMMITTER_EMAIL` is unset, committer email to " \ + "this value.", + }, + HOMEBREW_GIT_COMMITTER_EMAIL: { + description: "Set the Git committer email to this value.", }, HOMEBREW_GIT_NAME: { - description: "Set the Git author and committer name to this value.", + description: "Set the Git author name and, if `HOMEBREW_GIT_COMMITTER_NAME` is unset, committer name to " \ + "this value.", + }, + HOMEBREW_GIT_COMMITTER_NAME: { + description: "Set the Git committer name to this value.", }, HOMEBREW_GIT_PATH: { description: "Linux only: Set this value to a new enough `git` executable for Homebrew to use.", diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi index d8e7fbb8b290b..31f11f8b65778 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi @@ -160,6 +160,12 @@ module Homebrew::EnvConfig sig { returns(T.nilable(::String)) } def ftp_proxy; end + sig { returns(T.nilable(::String)) } + def git_committer_email; end + + sig { returns(T.nilable(::String)) } + def git_committer_name; end + sig { returns(T.nilable(::String)) } def git_email; end diff --git a/Library/Homebrew/utils/git.rb b/Library/Homebrew/utils/git.rb index cd7649f7defd1..994ae07ca263a 100644 --- a/Library/Homebrew/utils/git.rb +++ b/Library/Homebrew/utils/git.rb @@ -119,10 +119,19 @@ def self.set_name_email!(author: true, committer: true) ENV["GIT_COMMITTER_NAME"] = Homebrew::EnvConfig.git_name if committer end - return unless Homebrew::EnvConfig.git_email + if Homebrew::EnvConfig.git_committer_name && committer + ENV["GIT_COMMITTER_NAME"] = Homebrew::EnvConfig.git_committer_name + end + + if Homebrew::EnvConfig.git_email + ENV["GIT_AUTHOR_EMAIL"] = Homebrew::EnvConfig.git_email if author + ENV["GIT_COMMITTER_EMAIL"] = Homebrew::EnvConfig.git_email if committer + end + + return unless committer + return unless Homebrew::EnvConfig.git_committer_email - ENV["GIT_AUTHOR_EMAIL"] = Homebrew::EnvConfig.git_email if author - ENV["GIT_COMMITTER_EMAIL"] = Homebrew::EnvConfig.git_email if committer + ENV["GIT_COMMITTER_EMAIL"] = Homebrew::EnvConfig.git_committer_email end def self.setup_gpg! diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 903116d46d255..64d1186ed25cf 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -756,6 +756,7 @@ def self.create_bump_pr(info, args:) safe_system "git", "add", *changed_files safe_system "git", "checkout", "--no-track", "-b", branch, "#{remote}/#{remote_branch}" unless args.commit? + Utils::Git.set_name_email! safe_system "git", "commit", "--no-edit", "--verbose", "--message=#{commit_message}", "--", *changed_files