- provide log message on every commit (class logChecker)
- block removing of "/tags", "/branches" and "/trunk" directories from repo (class pathChecker)
- forcing branch and tag naming convention
- making subdirectories under /tags read-only
My company is running Subversion for storing all software packages and our repo hasn't got the default structure (/tags, /trunk and /branches as a top directories) — instead of that every package has got it's own /trunk, /tags and /branches subdirectories. So the repository structure is something like this:
/Path/
PackageA/
trunk/
src/
doc/
tags/
PackageA-00-00-00/
src/
doc/
...
branches/
PackageA-00-00-00-branch/
src/
doc/
PackageB/
...
/OtherPath/
PackageC/
...
Looks rather complicated, but it isn't. ;)
Also we've got tags and branches naming convention. Every tag should be made of package name, then a three (or four for tags made over a branch) groups of digits, e.g.: PackageName-ii-jj-kk or PackageName-ii-jj-kk-ll.
Every branch name is very similar to tag name, except there is additional (-branch) string at the end.
So here is the hook itself:
If you want to use this one, you have to modify it a little:
- replace 'librarian' or/and 'root' account name with your own repository admin
- put repository admin mail to block messages - replace this fake 'librarian@mail' address
- change regexp ffor tags and branches to match your criteria
- put svn-policy.py script into your repository hook directory ($REPO/hooks)
- modify "$REPO/hooks/pre-commit" script to switch this one on
#!/bin/sh
REPOS="$1"
TXN="$2"
SVNPOLICY=/path/to/repo/hooks/svn-policy.py # modify this line
#SVN policy
$SVNPOLICY -t "$TXN" "$REPOS" || exit 1
# All checks passed, so allow the commit.
exit 0
Maybe the code needs some cleaning and better structure but anyway happy using, comments and questions are welcome!
Cheers,
Krzysztof
Brak komentarzy:
Prześlij komentarz