3

我想对正在提交的文本文件运行以下脚本:

# 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 钩子,但我无法遵循有关如何使用上述脚本处理文本文件的文档。

4

1 回答 1

7

您的意思是在提交之前更改文本文件?您可以(我不确定如何),但这通常不是一个好主意,因为它不会告诉客户有关更改的信息,因此本地副本在提交时变为无效。

我要做的是阻止提交(非零退出),并给出一条错误消息,说明您为什么不希望该修订通过。

于 2008-09-02T01:04:55.243 回答