Tuesday, June 29, 2010

Adding a pre-comit hook to simulate "global ignores" at visual svn server

This one is one of the few (but kinda big) problems we are having with Subversion:  The inability to set global, server side ignores.  Unless all developers remember to add the usual java *.class, classes etc (or .dll, .exe, .suo, etc for .net) from their SVN client,  then you end up with all kinds of unwanted files in your svn repository. 

So here's the setup:  Visual SVN Server on Windows Server 2003, development using jdeveloper 10.1.2 (our customers are yet to upgade their OAS) on Windows 7 and Tortoise SVN clients.
And here's what we did:
Step 1:
We entered all ignored file extensions and file names in a file called ignoreFiles.txt, and all ignored folders in file ignoreFolders.txt.  The entries are one per line.

Step 2:
Developed a vb script that opens these 2 files and compares them agains all added files and folders in the current svn transation.  The vbscript is here

Step 3:
Access your SVN Server, right click on the repository name, and choose Propetrties.  From the properties page, choose "Hooks", then Pre-commit hook, edit and copy/paste the following pre comit trigger.
Then click OK, and you are done.  To test this, SVN-Checkout a test directory, create a couple of "illegal" files and folders and then try to commit.  You should get an error message.

No comments:

Post a Comment