修改预提交钩子脚本

时间:2011-12-15 12:04:15

标签: svn tortoisesvn

我有一个像这样的剧本

#!/bin/sh
REPOS=”$1"
TXN=”$2"
# Make sure that the log message contains some text.
SVNLOOK=/usr/local/bin/svnlook
$SVNLOOK log -t “$TXN” “$REPOS” | grep “[A-z a-z]” && exit 0
echo “Please write a log message describing the purpose of your changes and then try c   
ommitting again.” 1>&2
exit 1

如果我必须只跟踪svnlook中的cpp文件并在条件失败时抛出错误,我还应该用这个脚本添加什么? )grep和find逻辑不起作用**

1 个答案:

答案 0 :(得分:0)

因此,请准确解释您的需求:

  1. 如果所有文件都是.cpp个文件,则需要检查提交注释。否则,您要忽略该评论。
  2. 如果某些文件是.cpp个文件,则需要检查提交注释。否则,您要忽略该评论。
  3. 您只需要存储库中的.cpp个文件。没有其他的。并且,您要拒绝任何包含非C ++文件的提交。
  4. 无论您正在做什么,您都必须运行svnlook changed命令并查看已更改的文件的所有内容。请记住,所有提交的文件只有一个提交注释。

    如果你的问题涉及理由#3,我会感到惊讶。 C开发当然需要Unix方面的Makefiles,如果你使用的IDE允许你指定没有Makefile的构建,那么就有某种项目文件必须存储。< / p>

    您可能想要结帐我的kitchen sink pre-commit hook。这个预提交钩子几乎可以处理你想要的任何情况。它使用控制文件进行配置,因此您无需修改​​代码。

    想阻止人们处理任何非C ++文件吗?

    # Remove all permission
    [file You don't have permission to add these files to the repository]
    match = .*
    access = read-only
    users = @ALL
    
    # Allow only files ending in .cpp
    [file You don't have permission to add these types of files to the repository]
    file = **/*.cpp
    access = read-write
    users = @ALL
    
    # Users must be able to add directories
    [file You don't have permission to add these types of files to the repository]
    match = /$
    access = read-write
    users = @ALL
    
    # Probably want to allow the addition of Makefiles too
    [file You don't have permission to add these types of files to the repository]
    match = [mM]akefile$
    access = read-write
    users = @ALL
    

    想确保提交评论有效吗?

    [revprop You must add a VALID comment to your commits]
    property = svn:log
    value = .{10,}
    type = regex