在TortoiseSVN中,提交后添加评论?

发布于 2024-11-08 16:11:36 字数 277 浏览 0 评论 0 原文

可能的重复:
我可以返回并编辑 SVN 上的评论吗签到?

偶尔我会无意中提交一个文件而不添加注释(我们应该对每个提交进行注释,无论更改有多么微不足道)。有没有办法在提交后添加评论而无需恢复和重新提交?

Possible Duplicate:
Can I go back and edit comments on an SVN checkin?

Once in a rare while I inadvertently commit a file without commenting (we're supposed to comment on every commit no matter how trivial the change). Is there a way to add a comment after committing without reverting and recommitting?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甜宝宝 2024-11-15 16:11:36

除了按照 我可以返回并编辑 SVN 签入的评论吗?

svn propset --revprop -r 1000 svn:log "Not blank"

您应该考虑创建一个预提交挂钩将阻止您在没有提交消息的情况下签入。它可以位于服务器上,甚至可以位于您的本地副本上。屏幕截图,由于您使用的是 TortoiseSVN:

在此处输入图像描述

毕竟,预防胜于治疗!

防止在没有提交消息的情况下提交的示例预提交:

for %%I in (%3) Do (
IF %%~zI==0 (
echo "No commit message given" 1>&2
exit 1
)
)

我的 bash 知识有限,但上述方法似乎有效。如果需要,您当然可以使用 Python、Ruby 等语言编写脚本。基本上,第三个参数是包含提交消息的临时文件。查看是否为空,如果是则退出。

Apart from doing a propset on svn:log using something like below as suggested from Can I go back and edit comments on an SVN checkin?:

svn propset --revprop -r 1000 svn:log "Not blank"

you should consider creating a pre-commit hook that will prevent you from checking in without a commit message. This can be on the server or even on your local copy. Screenshot, since you are using TortoiseSVN:

enter image description here

After all, prevention is better than cure!

Sample pre-commit to prevent committing with no commit message:

for %%I in (%3) Do (
IF %%~zI==0 (
echo "No commit message given" 1>&2
exit 1
)
)

My bash knowledge is limited, but the above seems to work. You can of course have a script in Python, Ruby etc. if needed. Basically, the third parameter is a temporary file that contains the commit message. See if it is empty and exit if so.

仅此而已 2024-11-15 16:11:36

FAQ 中,有一种机制可以使用 pre -revprop-change 挂钩,或 svnadmin setlog 命令(如果您对存储库有本地访问权限,我怀疑您没有),但是在团队环境中我建议恢复和重新提交可能是更好的选择。

From the FAQ, there is a mechanism available using the pre-revprop-change hook, or the svnadmin setlog command (if you have local access to the repository, which I suspect you don't), however in a team environment I would suggest that the revert & recommit is probably a better choice.

定格我的天空 2024-11-15 16:11:36

我将这两者视为最佳实践:

  1. 需要对提交发表评论(需要预提交挂钩)
  2. 允许编辑现有评论(需要 pre-revprop-change 挂钩)

I发现后者很有用,因为它允许您返回并修改写得不好、不准确或只是很糟糕(例如“已修复”:-)的消息。

对于前者,最好安装在服务器上——这样它就会自动应用于每个人。如果您要求用户在客户端进行设置,则新用户很可能会忘记这样做。

安装钩子就像将钩子脚本放置在存储库的 hooks 目录中一样简单。事实上,当您创建存储库时,它会使用示例挂钩脚本填充 hooks 目录;不过,它们采用 Unix/Linux shell 脚本,因此如果您的服务器是基于 Windows 的,则需要查找(或编写)其他版本。碰巧的是,SO问题Common Types of Subversion Hooks提供了Windows版本的很少有钩子,包括上面提到的两个。

有关 Subversion 挂钩的完整详细信息,请参阅 服务器端 Subversion Book 第 5 章中的“实现存储库挂钩”和 < a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-settings.html#tsvn-dug-settings-hooks" rel="nofollow noreferrer">客户端挂钩脚本 客户端 TortoiseSVN 手册的第 4 章。

I would consider both of these as best practices:

  1. Require comments on commit (pre-commit hook needed)
  2. Allow editing of existing comments (pre-revprop-change hook needed)

I find the latter useful because it allows you to go back and revise poorly written, inaccurate, or just plain bad (e.g. "Fixed" :-) messages.

Regarding the former, it is best to install on the server--that way it applies to everyone automatically. If you require users to set it up on the client side, you run the chance of a new user forgetting to do so.

Installing a hook is as simple as placing a hook script in the hooks directory of the repository. In fact, when you create a repository it populates the hooks directory with sample hook scripts; they are in Unix/Linux shell script, though, so if your server is Windows-based you need to find (or write) other versions. As it happens, the SO question Common Types of Subversion Hooks provides Windows versions of a few hooks including both of those mentioned above.

For full details on Subversion hooks, see Implementing Repository Hooks in Chapter 5 of the Subversion Book for server side and Client Side Hook Scripts in Chapter 4 of the TortoiseSVN manual for client side.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文