我想在我的 git 存储库之一中使用 git-multimail 作为后接收 Hook (未使用 gitolite)。不幸的是,我无法让它工作,而且我几乎没有任何使用 Python 的经验。
到目前为止我做了什么:
- 我将以下 block 添加到
project.git/config
文件中:
[multimailhook]
mailingList = <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f89d95999194b89d80999588949dd69b9795" rel="noreferrer noopener nofollow">[email protected]</a>
from = <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3b5e565a52577b5e435a564b575e15585456" rel="noreferrer noopener nofollow">[email protected]</a>
envelopeSender = <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aecbc3cfc7c2eecbd6cfc3dec2cb80cdc1c3" rel="noreferrer noopener nofollow">[email protected]</a>
mailer = smtp
smtpServer = smtp.mydomain.com
smtpUser = myUser
smtpPass = myPassword
请注意,我不知道我的计算机上是否安装了 mailer
变量中定义的“smtp”。
- 我将当前的
git_multimail.py
文件复制到project.git/hooks
中。 - 我创建了一个包含以下内容的
project.git/hook/post-receive
文件。该文件是可执行的,我从 https://github.com/git-multimail/git-multimail/blob/master/git-multimail/post-receive.example 复制了它
#! /usr/bin/env python
import sys
import os
import git_multimail
config = git_multimail.Config('multimailhook')
try:
environment = git_multimail.GenericEnvironment(config=config)
#environment = git_multimail.GitoliteEnvironment(config=config)
except git_multimail.ConfigurationException:
sys.stderr.write('*** %s\n' % sys.exc_info()[1])
sys.exit(1)
mailer = git_multimail.choose_mailer(config, environment)
git_multimail.run_as_post_receive_hook(environment, mailer)
会发生什么:
当我推送更改时,会创建一个文件 project.git/hooks/git_multimail.pyc
,但不会发送电子邮件。
按照https://github.com/git-multimail/git-multimail/blob/master/doc/troubleshooting.rst上的描述使用GIT_MULTIMAIL_CHECK_SETUP=true python git_multimail.py
进行配置测试告诉我,git-multimail似乎已正确设置
有没有办法记录脚本输出之类的内容?我可以做什么来找出什么不起作用?我的文件中是否有错误?
提前致谢。
最佳答案
到目前为止,使用 post-receive.example
并不是设置 git_multimail.py
最简单的方法:正如 post-receive.example 脚本的标题所示:
The simplest way to use git-multimail is to use the script git_multimail.py directly as a post-receive hook, and to configure it using Git's configuration files and command-line parameters.
换句话说,只是
cp /path/to/git_multimail.py /path/to/project.git/hooks/post-receive
一切都准备好了(因为您已经填写了 project.git/config
)。请参阅Invocation in git-multimail's README了解更多详细信息。
(注意:不可否认,该文档对于初学者来说不太清楚,I'll try to improve that when I get time)
关于python - 如何调试/正确设置 git-multimail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39489274/