如何调试/正确设置gitmultimai

2024-06-07 10:53:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用git-multimail作为git存储库中的post receive钩子(没有使用gitolite)。不幸的是,我不能让它工作,而且我几乎没有任何使用Python的经验。在

到目前为止我所做的:

  1. 我将以下块添加到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”是否安装在我的机器上。在

  1. 我将当前的git_multimail.py文件复制到project.git/hooks。在
  2. 我用以下内容创建了一个project.git/hook/post-receive文件。文件是可执行的,我是从https://github.com/git-multimail/git-multimail/blob/master/git-multimail/post-receive.example复制的

^{pr2}$

发生了什么:

当我推送更改时,会创建一个文件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 seems properly set up

有没有一种方法可以记录脚本的输出?我该怎么做才能找出什么不起作用?我的文件甚至有错误吗?在

提前谢谢。在


Tags: 文件pyhttpsgitgithubprojectcomexample
2条回答

好吧,伙计们,错误可能是最小的。我在post receive hook文件中只犯了一个非常小的错误:sys.exit(1)命令没有缩进。在

所以,从我的问题来看是错误的:

try:
    environment = git_multimail.GenericEnvironment(config=config)
except git_multimail.ConfigurationException:
    sys.stderr.write('*** %s\n' % sys.exc_info()[1])
sys.exit(1)

正确的是(比较最后一行):

^{pr2}$

就像我说的,我几乎不懂Python,所以我没有注意到缩进。在更正了这一点之后,电子邮件就被发送了,所以您可以使用上面的步骤作为一个小教程来设置git multimail,这是“最简单”的方法。(我没有找到关于这个精确解决方案的教程。)

到目前为止,使用post-receive.example并不是设置{}:作为post头的最简单方法-示例.receive脚本上写着:

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。在

(注:令人钦佩的是,对于初学者来说,doc不是很清楚,I'll try to improve that when I get time

相关问题 更多 >

    热门问题