2

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

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

#!/bin/sh

export USER_EMAIL=from-email-address@blah.com
$(dirname $0)/post-receive-email
4

3 回答 3

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

您还可以映射电子邮件地址,例如,如果人们使用他们的 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

.mailmap 您可以在此处阅读更多信息。

于 2010-03-14T22:38:24.040 回答
1

您可以尝试另一个钩子系统,例如http://github.com/jtek/git-hook-update-notify-email

于 2010-03-14T22:07:02.803 回答
1

以下可能更好,以正确处理分支上的提交(在 Debian 系统上使用):

#! /bin/sh
git config hooks.envelopesender $(git log -all -1 --pretty=format:%ae)
. /usr/share/git-core/contrib/hooks/post-receive-email

git log --all不是git log HEAD将使用所有分支上的最新提交,据说是正确的通知。

git config hooks.envelopesender可以用上面提到的另一种变体代替。YMMV。

于 2014-02-25T15:57:41.723 回答