svn-pre-commit.pl - configurable pre-commit
hook for subversion.
svn-pre-commit.pl [--help, --man or other options] REPOS TXN
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.
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 a pre-commit
hook by subversion. See -g
option below.
Use default configuration. Do not look for any INI file.
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
This help.
More help.
Override the default value of a parameter in a section.
Specify explicitely which svnlook
command to use.
Path to temporary directory to use, if needed. Default is /tmp
.
Be verbose. Repeat for more.
Show script revision and exit.
The script expects two arguments, which are mandatory but for help, man, version, and configuration generation options.
Directory path to the subversion repository.
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.
This script may be invoked:
for instance by linking it as pre-commit
, in which case the configuration
is looked for as conf/svn-pre-commit.conf
within the repository, or the
default configuration is used.
in which case the hook script may invoke other checks, and additional options can be passed.
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
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 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.
Check for replaced files.
Filter out multi-level svn:mergeinfo
properties on a path.
Check allowed characters in file and directory paths.
Filter filenames.
Filter dirnames.
Check for allowed or denied suffixes.
Filter out added empty directories.
Check for svn conflict markers in files.
Check for maximum file size.
Append revision information about this script to generated messages.
Check svn:* file or directory property names.
Check non-svn file or directory property names.
Check property values.
Check svn:*
revision property names.
Check non-svn revision property names.
Check revision property values, for instance the log message.
(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 not responsible for anything. See http://www.gnu.org/copyleft/gpl.html for details.
The latest version of the script is available at http://www.coelho.net/svn-pre-commit.pl.
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.
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.
This documentation is about $Revision: 688 $ of the script.