【问题标题】:Automating Review Requests with ReviewBoard and Mercurial using Python hooks使用 Python 钩子通过 ReviewBoard 和 Mercurial 自动化审查请求
【发布时间】:2011-12-02 07:39:45
【问题描述】:

这是我的问题:

我有一个远程 mercurial 存储库,其中将设置传入或更改组的钩子,并且我在不同的服务器上设置了 ReviewBoard。 这个想法是在从开发人员推送到远程存储库时自动生成审查请求票证。 当然,我需要一个调用 post-review 的钩子,该钩子还使用使用 mercurial api (ctx.user()) 提取的 submit-as 用户,否则所有评论请求票证都将以用户的名义将远程存储库连接到 Reviewboard 服务器。

我的主要困境实际上是获取 start revision 和 stop revision ,如果我使用传入,我将获取所有变更集节点,但当然每次都会调用钩子,因此每次调用之间不会保留任何状态。另一方面,如果我使用变更组,我只会得到第一个变更集,我无法比较。为了比较,我需要一种方法来保留以前的提示,以便基本上将其发送到后期审查:

post-review --revision-range=previoustip:newtip --submit-as=ctx.user() 

如果您对如何解决问题有任何想法,我会很高兴。我显然正在用python编写钩子。

【问题讨论】:

    标签: python mercurial automation mercurial-hook review-board


    【解决方案1】:

    不确定这是否正是您所需要的,但这是我在几乎相同的情况下用于执行提交消息检查的东西,它必须检查每个更改并根据用户验证信息。以同样的方式,我需要检查更改列表所针对的用户,而不是“推送”用户。 在循环通过更改组中的更改时,应该很容易做一些事情,例如为特定用户构建更改集以及“块”中的开始和结束修订。

    return 是因为它被用作 pretxnchangegroup 钩子

    def checkAllCommitMessage(ui, repo, node, **kwargs):
        """    
        Checks all inbound changeset messages from a push for adherence to the commit message rules.
        """
    
        # for each change being submitted
        # get all the details, and call the trigger
        fail = False
    
        for rev in xrange(repo[node].rev(), len(repo)):
            # get context (change)
            ctx = repo[rev]
    
            # user who commited the change (NOT necessarily the one who is doing push)
            user = ctx.user()
    
            # do the hook stuff here...
            # set fail to True if something goes wrong
    
        return fail
    

    【讨论】:

    • 刚刚从我的圣诞假期回来:)。会试一试,让您随时了解情况(并更新积分)。
    • 我没有忘记这一点。我最近有很多事情要做。
    • 谢谢,这正是我所需要的。答案已接受:)。很抱歉很晚才回复。疯狂的 3 个月。
    猜你喜欢
    • 2012-06-30
    • 1970-01-01
    • 1970-01-01
    • 2012-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多