## Subversion: Commit Pre-Hook to Enforce a Code Freeze

It is almost all done for you in this script. Copy this script in /path/to/svn/<repos>/hooks, call it pre-commit, change the permissions to make it executable. Then, all you have to do is add the following below the if there is bogosity comment in test_path_change:

  ### Test the path change as you see fit.  If there is bogosity,
### write to sys.stderr and return non-zero.
if "trunk/" in path.lower():
sys.stderr.write("Code Freeze: Nothing can be committed to trunk anymore.")
return 1
return 0


Simple (if you don’t have any file/directory containing the word “trunk/” somewhere…1). It is interesting to note the "blah" in string python notation which I have just discovered—quite handy.

1 You’ll then have a bit smarter, like checking the presence of the word branches, etc.

## Comment

 Name Remember Email Website Message Textile help