SVN预提交挂钩,避免更改标签子目录 [英] SVN pre-commit hook for avoiding changes to tags subdirectories
问题描述
是否有人清楚地说明如何添加预提交挂钩,以免更改标签子目录?
我已经搜索了很多互联网.我找到了此链接: SVN :: Hooks :: DenyChanges ,但是我可以似乎无法编译东西.
我对Raim的回答没有足够的声誉来评论",但是他的表现很好,除了一个例外,他的grep模式是错误的. >
我只是使用以下内容作为我的预提交钩子(我没有一个钩子,在这种情况下,您需要合并):
#!/bin/sh
REPOS="$1"
TXN="$2"
SVNLOOK=/opt/local/bin/svnlook
# Committing to tags is not allowed
$SVNLOOK changed -t "$TXN" "$REPOS" | grep "^U\W.*\/tags\/" && /bin/echo "Cannot commit to tags!" 1>&2 && exit 1
# All checks passed, so allow the commit.
exit 0
Raim的grep模式的唯一问题是,如果它位于回购的根",则仅与标签"匹配.由于我的存储库中有多个项目,因此他编写的脚本允许在标签分支上进行提交.
此外,请确保按照指示使用chmod + x,否则您会认为它在提交失败后一直有效,但在操作失败时它无法执行预提交钩子,不是因为该钩子起作用了
这真的很棒,谢谢Raim.由于没有依赖性,因此比其他所有建议都更好,更轻巧!
Is there anybody who has clear instructions on how to add a pre-commit hook that avoids changes to tags subdirectories?
I already searched the internet quite a bit. I found this link: SVN::Hooks::DenyChanges , but I can't seem to compile things.
I don't have enough reputation to "comment" on Raim's answer above, but his worked great, with one exception, his grep pattern is wrong.
I simply used the below as my pre-commit hook (I didn't have an existing one, you'd need to merge in that case):
#!/bin/sh
REPOS="$1"
TXN="$2"
SVNLOOK=/opt/local/bin/svnlook
# Committing to tags is not allowed
$SVNLOOK changed -t "$TXN" "$REPOS" | grep "^U\W.*\/tags\/" && /bin/echo "Cannot commit to tags!" 1>&2 && exit 1
# All checks passed, so allow the commit.
exit 0
The only problem with Raim's grep pattern is that it only matched "tags" if it was at the "root" of your repo. Since I have several projects in my repo, the script as he wrote it allowed commits on tag branches.
Also, be sure to chmod +x as indicated, otherwise you'll think it worked b/c the commit failed, but it failed b/c it couldn't exec the pre-commit hook, not because the hook worked.
This was really great, thanks Raim. Much better and lighter weight than all other suggestions as it has no dependencies!
这篇关于SVN预提交挂钩,避免更改标签子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!