我想使用 git-multimail作为我的一个 git 存储库中的 post receive Hook (未使用 gitolite)。不幸的是,我无法让它工作,而且我几乎没有使用 Python 的经验。
到目前为止我做了什么:
- 我将以下 block 添加到
project.git/config文件中:
[multimailhook]
mailingList = email@example.com
from = email@example.com
envelopeSender = email@example.com
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,但不会发送任何电子邮件。
使用 GIT_MULTIMAIL_CHECK_SETUP=true python git_multimail.py 进行配置测试,如 https://github.com/git-multimail/git-multimail/blob/master/doc/troubleshooting.rst 中所述告诉我 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)
