在 Tortoise SVN 中向用户预提交显示一条消息
我们使用 Tortoise SVN 进行源代码控制,并且已经设置了提交消息模板。
我还想在用户提交时向他们显示一些文本,这些文本不会包含在他们的提交消息中,类似于“不要忘记做 X!”。
这可能吗?
We use Tortoise SVN for source control, and have already set up a commit message template.
I would also like to display some text to the user when they commit, that doesn't get included in their commit message, along the lines of "Don't forget to do X!".
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用 设置了类似的环境Tortoise Docs 可以说:是的,是的! 操作涉及一个 Start-Commit Hook(填充用户应读取的行)和一个 Pre-Commit Hook(再次删除这些行) :
启动提交挂钩
该钩子传递三个参数:
PATH MESSAGEFILE CWD
。MESSAGEFILE
是将用于存储提交消息的临时文件的路径。您可以使用您的消息填充此临时文件不要忘记执行 X! 或者,您可以在消息前面添加一些您将在提交消息中视为注释并被过滤掉的内容。由于 Git 在提交消息中使用#
作为注释,我也做了同样的事情:以#
开头的每一行都会从提交消息中过滤掉。因此我会写下消息# Don't忘记做X!
。 Perl 中的示例实现(未经测试):Pre-Commit Hook
该挂钩传递四个参数:
PATH DEPTH MESSAGEFILE CWD
。预提交钩子的作用是过滤掉您在启动提交钩子中填充到MESSAGEFILE
中的消息(否则它将作为提交消息的一部分发送到服务器,这可能是不是你想要的)。要么删除您的消息,不要忘记执行 X!,或者 – 如果您使用我上面写的注释方法 – 删除以#
符号(或者与模式^\s*#
匹配),因为它是我们世界中的注释。我们可以扩展启动提交挂钩的文件来处理预提交的内容,因为参数的数量不同。调用哪个钩子由传递给脚本的参数计数决定(也未经测试):
要激活钩子,请打开 TortoiseSVN 的设置,转到
钩子脚本
并添加脚本一次作为开始提交挂钩和一次作为预提交挂钩。要调用的命令行是perl /path/to/script
。还要选中等待脚本完成
和运行时隐藏脚本
。注意
如果您需要向挂钩传递更多信息,您还可以在 TortoiseSVN 设置中分配挂钩时传递自定义参数。如果您分配自定义参数,这些参数将在默认参数之前传递到挂钩(如 docs)获得通过。
I have set up a similar environment using the Tortoise Docs and can say: Yes, it is! Operation involves a Start-Commit Hook that fills in the lines that the user shall read and a Pre-Commit Hook that removes thee lines again:
Start-Commit Hook
This hook gets passed three parameters:
PATH MESSAGEFILE CWD
.MESSAGEFILE
is the path to a temporary file that will be used for storing the commit message. You can fill this temporary file with your message Don't forget to do X! Or, you prefix your message with something that you will treat as comment in the commit message and gets filtered out. Since Git uses#
as comment in the commit message, I did the same: every line that starts with#
gets filtered out of the commit message. And therefore I'd write the message# Don't forget to do X!
. Sample implementation in Perl (untested):Pre-Commit Hook
This hook gets passed four parameters:
PATH DEPTH MESSAGEFILE CWD
. The job of the pre-commit hook is to filter out the message that you filled intoMESSAGEFILE
in in the start-commit hook (otherwise it will go as part of the commit message to the server and this probably isn't what you want). Either just delete your message Don't forget to do X! or – if you use the comment approach as I wrote above – delete every line that starts with a#
sign (or that matches the pattern^\s*#
) since it's a comment in our world.We could extend our file for the start-commit hook to handle also the pre-commit stuff since the number of parameters is different. The decision on which hook to call is made up of the parameter count passed to the script (also untested):
To activate the hooks, open the settings of TortoiseSVN, go to
hook scripts
and add the script once as start-commit hook and once as pre-commit hook. The command line to call would beperl /path/to/script
. And also checkWait for the script to finish
andHide script while running
.Note
If you need further information passed to the hooks, you could also pass custom parameters when you assign the hooks in the settings of TortoiseSVN. If you assign custom parameters, these get passed to the hook before the default parameters (as stated in the docs) get passed.
请参阅有关 客户端挂钩脚本的 TortoiseSVN 文档。
See the TortoiseSVN documentation about client side hook scripts.