Skip to content

Commit 1c98fcc

Browse files
authored
Merge pull request #18749 from Homebrew/git-committer-info
Support setting `GIT_COMMITTER_NAME` and `GIT_COMMITTER_EMAIL`
2 parents 284035d + 1fbe436 commit 1c98fcc

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

Library/Homebrew/env_config.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,19 @@ module EnvConfig
273273
HOMEBREW_GITHUB_PACKAGES_USER: {
274274
description: "Use this username when accessing the GitHub Packages Registry (where bottles may be stored).",
275275
},
276+
HOMEBREW_GIT_COMMITTER_EMAIL: {
277+
description: "Set the Git committer email to this value.",
278+
},
279+
HOMEBREW_GIT_COMMITTER_NAME: {
280+
description: "Set the Git committer name to this value.",
281+
},
276282
HOMEBREW_GIT_EMAIL: {
277-
description: "Set the Git author and committer email to this value.",
283+
description: "Set the Git author name and, if `HOMEBREW_GIT_COMMITTER_EMAIL` is unset, committer email to " \
284+
"this value.",
278285
},
279286
HOMEBREW_GIT_NAME: {
280-
description: "Set the Git author and committer name to this value.",
287+
description: "Set the Git author name and, if `HOMEBREW_GIT_COMMITTER_NAME` is unset, committer name to " \
288+
"this value.",
281289
},
282290
HOMEBREW_GIT_PATH: {
283291
description: "Linux only: Set this value to a new enough `git` executable for Homebrew to use.",

Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Library/Homebrew/utils/git.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,19 @@ def self.set_name_email!(author: true, committer: true)
119119
ENV["GIT_COMMITTER_NAME"] = Homebrew::EnvConfig.git_name if committer
120120
end
121121

122-
return unless Homebrew::EnvConfig.git_email
122+
if Homebrew::EnvConfig.git_committer_name && committer
123+
ENV["GIT_COMMITTER_NAME"] = Homebrew::EnvConfig.git_committer_name
124+
end
125+
126+
if Homebrew::EnvConfig.git_email
127+
ENV["GIT_AUTHOR_EMAIL"] = Homebrew::EnvConfig.git_email if author
128+
ENV["GIT_COMMITTER_EMAIL"] = Homebrew::EnvConfig.git_email if committer
129+
end
130+
131+
return unless committer
132+
return unless Homebrew::EnvConfig.git_committer_email
123133

124-
ENV["GIT_AUTHOR_EMAIL"] = Homebrew::EnvConfig.git_email if author
125-
ENV["GIT_COMMITTER_EMAIL"] = Homebrew::EnvConfig.git_email if committer
134+
ENV["GIT_COMMITTER_EMAIL"] = Homebrew::EnvConfig.git_committer_email
126135
end
127136

128137
def self.setup_gpg!

Library/Homebrew/utils/github.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ def self.create_bump_pr(info, args:)
756756

757757
safe_system "git", "add", *changed_files
758758
safe_system "git", "checkout", "--no-track", "-b", branch, "#{remote}/#{remote_branch}" unless args.commit?
759+
Utils::Git.set_name_email!
759760
safe_system "git", "commit", "--no-edit", "--verbose",
760761
"--message=#{commit_message}",
761762
"--", *changed_files

0 commit comments

Comments
 (0)