Skip to content

Commit

Permalink
Merge pull request #18749 from Homebrew/git-committer-info
Browse files Browse the repository at this point in the history
Support setting `GIT_COMMITTER_NAME` and `GIT_COMMITTER_EMAIL`
  • Loading branch information
MikeMcQuaid authored Nov 11, 2024
2 parents 284035d + 1fbe436 commit 1c98fcc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
12 changes: 10 additions & 2 deletions Library/Homebrew/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,19 @@ module EnvConfig
HOMEBREW_GITHUB_PACKAGES_USER: {
description: "Use this username when accessing the GitHub Packages Registry (where bottles may be stored).",
},
HOMEBREW_GIT_COMMITTER_EMAIL: {
description: "Set the Git committer email to this value.",
},
HOMEBREW_GIT_COMMITTER_NAME: {
description: "Set the Git committer name to this value.",
},
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_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_PATH: {
description: "Linux only: Set this value to a new enough `git` executable for Homebrew to use.",
Expand Down
6 changes: 6 additions & 0 deletions Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions Library/Homebrew/utils/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/utils/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1c98fcc

Please sign in to comment.