提交Subversion时可以修改文本文件吗? [英] Can you modify text files when committing to subversion?
问题描述
我要在要提交的文本文件上运行以下脚本:
I want to ran the following script on text files that are being committed:
# Send the commands H and w to ed
# ed will append newline if the file does not end in one
printf "%s\n" H w | ed -s $1
# Strip trailing whitespace
sed -i 's/[ \t]*$//g' $1
# Convert tabs to 4 spaces
sed -i -r "s/\t/ /g" $1
我看到Subversion有一个start-commit和pre-commit钩子,但是我无法遵循有关如何使用上述脚本处理文本文件的文档.
I see subversion has a start-commit and pre-commit hooks but I can't follow the documentation about how I could process the text files with the above script.
推荐答案
您的意思是在提交文本文件之前对其进行更改?您可以(我不确定如何),但这通常不是一个好主意,因为它不会告诉客户有关更改的信息,因此本地副本在提交时将变为无效.
You mean change the text file before it's committed? You can (I'm not sure how), but it's generally not a good idea, as it doesn't tell the client about the change, so the local copies become void on a commit.
我要做的是阻止提交(非零退出),并给出一条错误消息,说明为什么您不希望该修订通过.
What I would do is block the commit (non zero exit), and give an error message as to why you don't want that revision to go through.
这篇关于提交Subversion时可以修改文本文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!