我正在使用git附帶的post-receive-email腳本。 (來源是here。)它工作得很好,但我希望每封電子郵件都是從提交的作者發送的。我該怎麼做?如何讓git post-receive郵件從提交作者發送?
我的post-receive文件目前看起來像這樣,我想定製from-email-address。
#!/bin/sh
export [email protected]
$(dirname $0)/post-receive-email
我正在使用git附帶的post-receive-email腳本。 (來源是here。)它工作得很好,但我希望每封電子郵件都是從提交的作者發送的。我該怎麼做?如何讓git post-receive郵件從提交作者發送?
我的post-receive文件目前看起來像這樣,我想定製from-email-address。
#!/bin/sh
export [email protected]
$(dirname $0)/post-receive-email
使用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
here。
#! /bin/sh
git config hooks.envelopesender $(git log -all -1 --pretty=format:%ae)
. /usr/share/git-core/contrib/hooks/post-receive-email
的git log HEAD
git log --all
而是將使用最新的 提交所有分支上,按說:
你可以嘗試另一種鉤系統,如http://github.com/jtek/git-hook-update-notify-email
下可能會更好,要正確處理好犯下的 分支(Debian的系統上使用)製成正確的一個通知。
git config hooks.envelopesender
可能被替換爲另一個 上述變種。因人而異。
在較新的git它的git log -1 --pretty = format:%ae – 2ni 2011-04-26 10:31:33
它不適用於分支機構。如果某人在分支機構中進行提交,那麼提交者將始終是主機中的最後一個。 – 2ni 2011-04-27 01:29:52
你說得對,我有你提到的分支問題。你知道如何解決它嗎?它從來沒有讓我感到足夠的困擾,以查看它。 – 2011-04-27 20:25:13