如何强制将审阅者姓名输入到 SVN 提交评论中

发布于 2024-07-27 18:22:08 字数 476 浏览 3 评论 0原文

目前,我使用预提交挂钩阻止任何不包含注释的 SVN 提交。

现在我希望扩展它,以便提交注释必须包含

“审阅者:name

行。目前预提交挂钩文件看起来像

:: SET REPOS=%1

:: Transform forward-slashes to back-slashes for Windows
:: SET REPOS=%REPOS:/=^\%

"C:\Program Files\VisualSVN Server\bin\svnlook.exe" log -t %2 %1 | FindStr [a-zA-Z0-9]
IF %ERRORLEVEL% EQU 0 GOTO CHECKSUOFILES
echo "Commit Comments are Required" >&2
exit 1 

有人实现了类似的东西吗?

我目前使用的是SVN 1.6.0

I currently block any commit to SVN that does not contain a comment using pre-commit hooks.

Now I wish to extend this so that the Commit comment must have the line

"Reviewed by: name"

Currently the pre commit hook file looks like

:: SET REPOS=%1

:: Transform forward-slashes to back-slashes for Windows
:: SET REPOS=%REPOS:/=^\%

"C:\Program Files\VisualSVN Server\bin\svnlook.exe" log -t %2 %1 | FindStr [a-zA-Z0-9]
IF %ERRORLEVEL% EQU 0 GOTO CHECKSUOFILES
echo "Commit Comments are Required" >&2
exit 1 

Has anyone implemented something similar?

I am currently using SVN 1.6.0

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

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

发布评论

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

评论(4

爱本泡沫多脆弱 2024-08-03 18:22:08

对我来说,这似乎是不好的做法 - 强制审查某些内容会抑制频繁的签入,而这是您想要鼓励的事情之一。 总的来说,我对使用版本控制软件作为某种工作流管理系统的明显趋势感到有点沮丧 - 这根本不是它的目的!

This seems like bad practice to me - forcing something to be reviewed will inhibit frequent checkins, which is one of the things you want to encourage. In general, I am a bit dismayed by the apparent trend to use version control software as some sort of workflow management system - that is not what it is intended for at all!

森林很绿却致人迷途 2024-08-03 18:22:08

我采取了相当原始的路线来回答我自己的问题。 我更改了预提交挂钩以查找文本“审阅者:”,否则它将阻止提交

这有问题

  • 您可以通过输入审阅者:而不是名称来规避它
  • 我们要求开发人员输入审核者:未经审核的提交无人审核

但是,它将允许我们解析 SVN 日志以查看哪些内容已经/尚未审核以及由谁审核。

I took a fairly primitive route to answer my own question. I altered the pre commit hook to look for the text "Reviewed by: " or else it will block the commit

There are problems with this

  • You can circumvent it just by entering the Reviewed By: and then not a name
  • We are asking developers to enter Reviewed by: No-one for un-reviewed commits

However it will allow us to parse the SVN logs to see what has/hasn't been reviewed and by whom.

怪异←思 2024-08-03 18:22:08

基本上你已经有一个例子了。 只需添加类似:

set reviewed=no
"C:\Program Files\VisualSVN Server\bin\svnlook.exe" log -t %2 %1 | FindStr "reviewed by" && set reviewed=yes
if "%reviewed%"=="no" GOTO NOTREVIEWED

但是。

当更改已经提交时,查看更改是最容易的。 另外,正如尼尔已经提到的,您不想阻止定期的一口大小提交。 审查巨大的变化效果并不好。

如果您确实想确保每个更改都经过审查,则应该使用 功能分支。 为每个更改创建一个分支,并允许频繁的小提交,而无需在那里进行审查。 当更改准备就绪时,审阅者可以逐次检查它,并将更改合并到主干中。

You basically already have an example right there. Just add something like:

set reviewed=no
"C:\Program Files\VisualSVN Server\bin\svnlook.exe" log -t %2 %1 | FindStr "reviewed by" && set reviewed=yes
if "%reviewed%"=="no" GOTO NOTREVIEWED

However.

Reviewing a change is easiest when the change has already been committed. Also, as already mentioned by Neil, you don't want to discourage regular bite size commits. Reviewing huge blobs of change doesn't work well.

If you really want to make sure that every change is reviewed, you should use the concept of feature branches. Make a branch for each change, and allow frequent small commits without reviews there. When the change is ready, the reviewer can examine it commit by commit and merge the changes into trunk.

方觉久 2024-08-03 18:22:08

您可能想考虑使用 Git ( http://git-scm.com/ ) 之类的东西SVN 的。 使用 Git,您可以拥有项目的“祝福”版本,该版本只能由您的审阅者写入。 所有个人都在本地计算机上使用代码,并且可以将他们的更改推送到项目的“审查”实例。 审阅者可以在“review”实例中看到更改,并将各个更改推送到“blessed”版本。

Git 还可以直接转换您现有的 SVN 项目。

You might want to look into using something like Git ( http://git-scm.com/ ) instead of SVN. With Git, you can have a "blessed" version of the project that can only be written to by your reviewers. The individuals all work with the code on their local machines and can push their changes up to a "review" instance of the project. The reviewers can see the changes in the "review" instance and push individual changes up to the "blessed" version.

Git can also convert your existing SVN projects directly.

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