svn-pre-commit
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 subversion
pre-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.conf
if available within the repository, so that the script can be invoked directly as apre-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 for help, 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 prior commits, 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 configuration is looked for asconf/svn-pre-commit.conf
within the repository, or the default configuration is used. -
indirectly from a hook script
in which case the hook script may invoke other checks, and additional options can be passed.
-
directly from a shell
For testing, for instance to check what would be the result on a previous revision 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 described above. 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 some keyword 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
This is free software, both inexpensive and available with sources.
This script is distributed under the term of the Apache License version 2.0, https://www.apache.org/licenses/LICENSE-2.0.
This script has been initially developed by Fabien Coelho under the GPLv3.
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, the
former 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 bindings which access the repository contents directly instead on relying on svnlook.
The script is not nicely extensible, say with some clever object-oriented
interface or the like, possibly in python
.
It is just plain perl
.
I like that.
Running svnlook pl
on revision properties within a transaction does not
seem 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 is coming and the urgent work is bounced. You won't get many thanks for deploying such a script.
VERSION
This documentation is about $Revision: 692 $ of the script.