Hi all,
While working with the tracker, I noticed that:
1) From time to time error mails are generated when invalid commits are done.
2) A syntax checker exists.
This sounds like an ideal use case for a pre-commit SVN hook: the commit is
checked for syntax, and rejected to the user when the syntax is not right.
This will prevent errors from being commited in the first place, evading:
- Error mails;
- Extra commits to fix stuff;
- Spurious log entires related to that.
Please see attached the following files I propose to put in svn's hooks dir.
I've tested it on a test repository and it seems to work just fine. If you
commit something invalid, you get:
$ svn commit -m test
Sending data/CVE/list
Transmitting file data .svn: Commit failed (details follow):
svn: MERGE request failed on '/svn/test/data/CVE'
svn: 'pre-commit' hook failed with error output:
Traceback (most recent call last):
File "bin/check-syntax", line 75, in ?
file_types[sys.argv[1]](sys.argv[2])
File "bin/check-syntax", line 55, in parse_CVE
do_parse(f)
File "bin/check-syntax", line 28, in do_parse
for r in f:
File "/tmp/test/lib/python/bugs.py", line 633, in __iter__
pkg_notes.append(
File "/tmp/test/lib/python/bugs.py", line 218, in __init__
raise SyntaxError , 'unknown package note %s\n' % `n`
SyntaxError: unknown package note 'bug 439226'
pre-commit is the actual hook; check-file is called from that. This is to keep
things separated when more pre-commit hooks might be added in the future. It
depends on a checkout of the repository in alioth, for the check-syntax
python script.
Let me know of any objections or comments.
Thijs
Attachment:
check-file
Description: application/shellscript
Attachment:
pre-commit
Description: application/shellscript
Attachment:
pgpVyyUlbZN_8.pgp
Description: PGP signature