Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Precommit hook for svn to modify files to be committed in c#

Tags:

c#

tortoisesvn

I want to modify in certain way(Actually format the files in a code formatter) before they are committed to repository. I have found out from Precommit example (Use guest as name and no password) how to write in python.But what i want to know is how to get list of files to be committed and other command line arguments this one takes.One more thing i prefer is to write my own pre commit hook in C# rather than Python or any other script.

Few points I will write a exe which will format,but i want the list of files being committed How to configure this with svn.

like image 777
Ravisha Avatar asked Dec 07 '22 04:12

Ravisha


2 Answers

Precommit hooks that modify the committed files are considered 'a bad thing':

http://svnbook.red-bean.com/en/1.5/svn.reposadmin.create.html#svn.reposadmin.create.hooks

The idea merits a big red box in the official SVN documentation, and warns that this will affect how the SVN client works with the repository in bad ways.

like image 93
John McAleely Avatar answered Dec 10 '22 02:12

John McAleely


The first parameter passed to the pre-commit hook script is a path to a text file. That text file contains all the paths which are to be committed, separated by newlines.

But for your situation, you might better use the start-commit hook: that script is called right before the commit begins, but after the user selected the files/folders to commit. The start-commit script is called after the user clicks OK in the commit dialog, and before the actual commit begins. This hook has a list of exactly what will be committed.

like image 23
Stefan Avatar answered Dec 10 '22 03:12

Stefan