SVN configurable pre-commit hook



SVN configurable pre-commit hook

r688 | coelho | 2011-09-07 11:47:15 +0200 (Wed, 07 Sep 2011)

NAME

svn-pre-commit.pl - configurable pre-commit hook for subversion.


SYNOPSIS

svn-pre-commit.pl [--help, --man or other options] REPOS TXN


DESCRIPTION

This script performs sanity checks about what is being committed.It is designed to be run directly or indirectly as a subversionpre-commit hook script.It is configured from an INI file.The main point of the script is to think again before committing:it can be configured to be forcible based on the log message contents.


OPTIONS

--configuration=inifile or -c inifile

Configuration file to use. Default is to use conf/svn-pre-commit.confif available within the repository, so that the script can be invoked directlyas a pre-commit hook by subversion. See -g option below.

--default or -d

Use default configuration. Do not look for any INI file.

--generate-configuration or -g

Generate the current configuration file on standard output.This can be redirected to a file and tailored as needed.

  sh> svn-pre-commit.pl -g > /path/to/repos/conf/svn-pre-commit.conf
  # then edit configuration file to your taste
--help or -h

This help.

--man or -m

More help.

--set section.parameter=value or -s sec.par=val

Override the default value of a parameter in a section.

--svnlook=/path/to/svnlook or -l /path/to/svnlook

Specify explicitely which svnlook command to use.

--temporary=/path/to/directory or <-t /tmp>

Path to temporary directory to use, if needed. Default is /tmp.

--verbose or -v

Be verbose. Repeat for more.

--version or -V

Show script revision and exit.


ARGUMENTS

The script expects two arguments, which are mandatory but forhelp, man, version, and configuration generation options.

REPOS

Directory path to the subversion repository.

TXN

Transaction or revision number.The revision number can be used to test the script configuration on priorcommits, to check for what would have been done with it.


INVOCATION

This script may be invoked:

directly as a hook script

for instance by linking it as pre-commit, in which case the configurationis looked for as conf/svn-pre-commit.conf within the repository, or thedefault configuration is used.

indirectly from a hook script

in which case the hook script may invoke other checks, and additional optionscan be passed.

directly from a shell

For testing, for instance to check what would be the result on a previousrevision in a given repository e.g.:

  sh> n=12345 ; \
      while let --n ; do \
        echo "### $n" ; \
        svn-pre-commit.pl /path/to/repos $n ; \
      done


CONFIGURATION

The configuration is stored in an INI file.The current configuration can be regenerated with the -g option describedabove.The output may be redirected to a file and modified to suit your needs.Use this option to see detailed parameters for each section.

The available sections are:

general

General settings, including whether the commit can be forced with somekeyword in the log message, and for each check whether it is activated.Part of the repository can be ignored by the script.

replace

Check for replaced files.

mergeinfo

Filter out multi-level svn:mergeinfo properties on a path.

path

Check allowed characters in file and directory paths.

filename

Filter filenames.

dirname

Filter dirnames.

suffix

Check for allowed or denied suffixes.

emptydir

Filter out added empty directories.

conflict

Check for svn conflict markers in files.

filesize

Check for maximum file size.

showinfo

Append revision information about this script to generated messages.

svnprops

Check svn:* file or directory property names.

otherprops

Check non-svn file or directory property names.

propvalues

Check property values.

svnrevprops

Check svn:* revision property names.

otherrevprops

Check non-svn revision property names.

revpropvalues

Check revision property values, for instance the log message.


LICENSE

GNU GPLv3

(c) 2009-2011 Fabien Coelho <svn-pre-commit at coelho dot net>http://www.coelho.net/

This is free software, both inexpensive and available with sources.The GNU General Public License v3 or more applies (GPLv3+).The brief summary is: You get as much as you paid for, and I am notresponsible for anything.See http://www.gnu.org/copyleft/gpl.html for details.


DOWNLOAD

The latest version of the script is available athttp://www.coelho.net/svn-pre-commit.pl.


INSTALLATION

Just put the script in your path, or copy it directly as a pre-commit hook.

The script relies on three perl modules: Config::IniFiles, Getopt::Long,and Pod::Usage. Although the two later modules are pretty standard, theformer one may need to be installed via your packaging system or using CPAN.For instance, package libconfig-inifiles-perl is needed on Debian/Ubuntu.See your system administrator.


BUGS

All softwares have bugs, this is a software, hence...

Maybe the implementation would be more efficient in python, using bindingswhich access the repository contents directly instead on relying on svnlook.

The script is not nicely extensible, say with some clever object-orientedinterface or the like, possibly in python.It is just plain perl.I like that.

Running svnlook pl on revision properties within a transaction does notseem to work with subversion 1.5. There is a partial workaround.

People do not like their commits to be rejected. Really.They usually do not read the error message.Enforcing a commit policy has a weak pedagogical value when a deadline iscoming and the urgent work is bounced.You won't get many thanks for deploying such a script.


VERSION

This documentation is about $Revision: 688 $ of the script.



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值