hook代码 svn_SVN提交代码时实现强制按固定格式填写Log的方法

SVN

提交代码时实现强制按固定格式填写

Log

的方法

SVN

本身并不提供这种强制填写

Log

的功能,

而是通过一系列的钩子程序

(

称为

hook

)

在提交之前

(pre-commit)

提交过程中

(start-commit)

提交之后

(post-commit)

调用

预定的钩子程序来完成一些附加的功能。

本次我们要实现的是在提交到版本库之前检查用户是否已经按固定格式填写了

Log

使用

pre-commit

这个钩子程序。打开

SVN

repository

目录下的

hook

子目录,有一个

“pre

-

commit.tmpl”文件。

这个文件是一个模板文件,

它告诉了我们如何实现提交前控制。

内容如下:

# The pre-commit hook is invoked before a Subversion txn is

# committed. Subversion runs this hook by invoking a program

# (script, executable, binary, etc.) named 'pre-commit' (for which

# this file is a template), with the following ordered arguments:

#

#

[1]REPOS-PATH (the path to this repository)

#

[2]TXN-NAME (the name of the txn about to be committed)

#

# The default working directory for the invocation is undefined, so

# the program should set one explicitly if it cares.

#

# If the hook program exits with success, the txn is committed; but

# if it exits with failure (non-zero), the txn is aborted, no commit

# takes place, and STDERR is returned to the client. The hook

# program can use the 'svnlook' utility to help it examine the txn.

在一个提交事务执行之前,

SVN

会调用指定的

hook

脚本,

并向该脚本传递了两个参数:

REPOS-PATH

(仓库路径)和

TXN-NAME

(本次事务的事务号)。可以在该脚本中进行一些检

查(比如检查

Log

信息是否填写),如果满足条件则返回

0

;否则返回其它非

0

结果,进而

提交失败。可以通过

svnlook

命令来检查是否已经写了

Log

目标:检查提交代码时是否按照以下格式填写了

Log

NGRBUG-xxx: yyy

或者

NGRDEV-xxx: (yyy) zzz

其中,

xxx

JIRA

编号,

yyy

JIRA

的标题,

zzz

为具体的提交说明。

下面分别就

SVN

服务器搭建在

Windows

上和

Linux

上两种情况下列出

pre-commit

脚本的内

容。

1.

SVN

服务器搭建在

Windows

hook

目录下创建

pre-commit.bat

文件,内容如下:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值