如何从提交作者发送git post-receive电子邮件?

Jon*_*ran 2 git email hook post-commit

我正在使用git附带的post-receive-email脚本.(来源在这里.)它工作正常,但我希望每个电子邮件都是从提交的作者发送的.我该怎么做?

我的post-receive文件目前看起来像这样,我想自定义from-email-address.

#!/bin/sh

export USER_EMAIL=from-email-address@blah.com
$(dirname $0)/post-receive-email
Run Code Online (Sandbox Code Playgroud)

Jon*_*ran 8

使用git log拉出的电子邮件地址.

例如,在post-receive:

#!/bin/sh

# Use the email address of the author of the last commit.
export USER_EMAIL=$(git log -1 --format=format:%ae HEAD)
$(dirname $0)/post-receive-email
Run Code Online (Sandbox Code Playgroud)

您还可以映射电子邮件地址,例如,人们正在使用他们的Gmail或个人域名地址,但您希望将它们映射到单个域.

#!/bin/sh

# Use the mapped email address (specified in .mailmap) of the author of the last commit.
export USER_EMAIL=$(git log -1 --format=format:%aE HEAD)
$(dirname $0)/post-receive-email
Run Code Online (Sandbox Code Playgroud)

你可以.mailmap 在这里阅读更多信息.