是否有相当于 git prepare commit message hook 的 SVN [英] Is there an SVN equivalent to the git prepare commit message hook

查看:37
本文介绍了是否有相当于 git prepare commit message hook 的 SVN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编辑传入的提交消息(添加分支名称,或添加一个忽略某些行的模板等).在我搜索时,我发现 git 有一个准备提交消息钩子,它似乎可以做到这一点,但 svn 没有.有没有办法在提交后在 svn 中做到这一点?

I want to edit the incoming commit messages (adding branch name, or add a template that has some lines ignored etc). While I was searching I found that git has a prepare commit message hook that seems to do this but svn doesn't. Is there a way to do this in svn before the post commit?

推荐答案

在 SVN 中你不需要使用钩子脚本来添加日志消息模板:

In SVN you do not need to use hook scripts to add log message templates:

  • 使用 TortoiseSVN 客户端,您可以并且应该使用 tsvn:* 属性.

使用 vanilla svn.exe 命令行客户端,使用 CMD_EDITOR 环境变量,用于定义您要调用的日志消息或使其根据提交中的更改自动确定日志消息.

With vanilla svn.exe command-line client, use CMD_EDITOR environment variable to define which log message you want to call or make it determine the log message automatically based on the changes in your commit.

使用 SVN 钩子脚本来验证,而不是修改.

调整 SVN 中现有修订的日志消息通常是一个单行命令.默认情况下,禁止修改日志消息.管理员始终可以允许所有用户或仅某些用户使用此功能.

Adjusting log messages for existing revisions in SVN is normally a one-line command. It is forbidden to modify the log messages, by default. An admin can always allow this to all or only certain users.

我猜你已经在使用 TortoiseSVN 客户端了,因为问题被标记为 标签.TortoiseSVN 支持多种属性,可以帮助您定义客户端的行为.他们将帮助您实施提交政策,包括日志消息限制和模板:

I guess that you already use TortoiseSVN client since the question is marked with windows tag. TortoiseSVN supports several properties that should help you define the behavior of the client. They will help you implement commit policies including log message restrictions and templates:

  • tsvn:logminsize 定义传入修订的日志消息必须包含的最少字符数.

  • tsvn:logminsize defines minimum number of characters the log message of the incoming revision must contain.

tsvn:logtemplate 将帮助您定义默认日志消息模板.还有 8 个额外的 tsvn:logtemplate 属性,您可以使用它们为不同类型的提交添加不同的模板.

tsvn:logtemplate will help you define default log message template. There are 8 additional tsvn:logtemplate properties that you can use to add different templates for different types of commits.

tsvn:logsummary 将帮助您定义正则表达式以获取提交消息的一部分,并在您使用 TortoiseSVN 查看修订历史日志时将其显示为摘要.

tsvn:logsummary will help you define regexp to grab a portion of commit message and display it as a summary when you view revision history log with TortoiseSVN.

请参阅手册的 TortoiseSVN 项目属性一章获取完整的属性列表及其用途.

See the TortoiseSVN Project Properties chapter of the manual for complete list of properties and their purpose.

您必须使用 git 的 pre-commit 钩子来验证日志消息并添加提交消息模板.如果您不这样做,则修复日志消息中的错误的过程需要您使用 git rebase 这可能很重要.可能还有其他方法可以添加日志消息策略,但在 git 的世界中,您必须为此使用钩子脚本.

You must use git's pre-commit hooks to validate the log messages and add commit message templates. If you don't do this, the procedure to fix the mistakes in log messages requires you to use git rebase that can be non-trivial. There could be other ways to add log message policies, but in git's world you have to use hook scripts for this.

不要忘记 svn commitgit commit 操作在使用 git 或 SVN 的常见工作流中扮演不同的角色.svn commitgit commit 操作的整体思路和结果是不同的.因此,*-commit 钩子在两个系统中都有不同的目标:

Don't forget that svn commit and git commit operations play different roles in common workflows with git or SVN. The whole idea and results of svn commit and git commit operations is different. Consequently, *-commit hooks have different goals in both systems:

  • 在本地 git 存储库中运行 git commit 是本地的、仅限客户端的操作.当你在 git 中提交时,你只制作本地快照,而无需联系受祝福的远程存储库.在这种情况下,使用本地钩子来自定义客户端的默认行为应该是完全没问题的.您的本地更改不会影响其他 git 用户,除非您通过推或拉发布它们.这是 git 工作流程的一部分,需要您最大程度地关注日志消息——重写提交的数据(包括日志消息)将迫使您的同事搁置当前任务并开始手动修复他们的本地存储库.

  • Running git commit in your local git repository is a local, client-side only operation. When you commit in git, you only make a local snapshot without contacting the blessed remote repository. In this case it should be perfectly fine to use local hooks to customize client's default behavior. Your local changes do not affect other git users unless you publish them by pushing or pulling. And this is the part of git's workflow that requires you to take maximum care about the log messages -- rewriting the commit's data (including the log message) will force your colleagues to put aside current tasks and begin manual repair of their local repos.

但是当您运行 svn commit 时,您会联系远程服务器以将您的本地更改发布到存储库,并以新修订的形式提供给其他开发人员.即使你在提交 SVN 时在日志消息中犯了错误,你也可以随时自己调整或询问有这种权限的同事.简单,不会造成任何伤害.

But when you run svn commit, you contact the remote server to publish your local changes to the repository and make them available in form of new revision to other developers. Even if you made a mistake in log message when you commit to SVN, you can always adjust it yourself or ask a colleague who has such privilege. Simple and no harm caused.

这篇关于是否有相当于 git prepare commit message hook 的 SVN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆