python - 如何调试/正确设置 git-multimail

标签 python git githooks post-receive-email

我想在我的 git 存储库之一中使用 git-multimail 作为后接收 Hook (未使用 gitolite)。不幸的是,我无法让它工作,而且我几乎没有任何使用 Python 的经验。

到目前为止我做了什么:

  1. 我将以下 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/

    相关文章:

    Python: float 无限长度(精度 float )

    c# - 将 README.md 文件添加到 Visual Studio 2015 中的 c# 项目

    git - 我如何知道在没有 merge 来自第二个父项的更改的两个父项的 Git 提交中发生了什么?

    python - 在 cython 中排序

    python - 将变量传递给需要引号的外部程序

    python - 为什么 '362' > 378?

    svn - 为什么要使用SVN?那里有任何 stash 的专业人士(通过 GIT/Mercurial/Bazaar)吗?

    git - 如何在 Jenkins 中一次只远程触发一个构建?

    git - 将参数传递给 git pre-push hook

    node.js - 在 WebStorm 和 SourceTree 中使用 NVM 时 Git Hooks 错误