SVN 预提交钩子相同的消息 [英] SVN Pre-Commit Hook For Identical Messages

查看:32
本文介绍了SVN 预提交钩子相同的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的同事很固执.一开始他们会在没有任何消息的情况下提交,所以我试图教育他们并放入一个预提交脚本以检查是否为空,以防他们忘记.然后他们会像已修复"一样输入消息,所以我再次与他们交谈并更新了脚本以强制它链接到错误跟踪器.现在,他们为同一个文件连续 8 次放入相同的提交消息(Bug ID:Bug Title).

My colleagues are very stubborn. At the beginning they would commit with no message so I tried to educate them and put in a pre-commit script to check for empty in case they forget. They would then put in messaged like "fixed" so I spoke to them again and updated the script to force it to link to the bug tracker. Now they are putting in the same commit message 8 times in a row for the same file (Bug ID: Bug Title).

在我与他们讨论这无济于事之后,我如何制作一个预提交钩子来检查提交消息是否与最后 20 条提交消息中的一条不同?

After I talk to them about how this isn't helpful, how can I make a pre-commit hook that checks that the commit message isn't identical to one of the last 20 commit messages?

推荐答案

svnlook 有 2 个选项组合在一起可以解决这个问题.

svnlook has 2 options that combined together can sort this out.

svnlook 日志 http://svnbook.red-bean.com/en/1.7/svn.ref.svnlook.c.log.html

svnlook log http://svnbook.red-bean.com/en/1.7/svn.ref.svnlook.c.log.html

svnlook 最年轻的 http://svnbook.red-bean.com/en/1.7/svn.ref.svnlook.c.youngest.html

svnlook youngest http://svnbook.red-bean.com/en/1.7/svn.ref.svnlook.c.youngest.html

Youngest 获得头部修正.然后我将最后 20 次提交回显到一个临时值.文件并使用 grep 在临时文件中搜索提交消息.文件.

Youngest gets the head revision. I then echo the last 20 commits to an temp. file and use grep to search for the commit message in the temp. file.

grep 选项是 F 用于使用文件作为输入,x 用于匹配整行,q 用于安静.

The grep options are F for using a file as input, x to match a whole line and q for quiet.

    #Prevent people putting in the same commit message multiple times by looking for an identical message in the last 20 commits
    ID=$(svnlook youngest $REPOS)
    COMMITS=/tmp/svncommits.txt
    rm $COMMITS
    for (( i=$ID-20; i<=$ID; i++ ))
    do
        echo $(svnlook log $REPOS -r $i) >> $COMMITS
    done

    if $(grep -Fxq "$COMMIT_MSG" "$COMMITS") ; then
        echo "Please describe what your change is, why you made it and don't use the same commit message every time." 1>&2
        exit 1
    fi

这篇关于SVN 预提交钩子相同的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆