Subversion Hook
Asked Answered
E

2

8

I am working in a project where there are configuration files, one in number for each of the environments where the application would be deployed.

When a developer modifies one of these files, the developer should not be allowed to check-in the file individually, but check-in all the files together or at least the developer should be informed that this needs to be done.

How can we achieve it?

Ehrenburg answered 24/11, 2008 at 11:37 Comment(0)
M
12

I would think you could write a pre-commit hook to do this - just have a list of files where if one is committed then they must all be committed.

You can write hooks in any language that you can write a command-line application in. The only gotcha is that they run in the context of the SVN server, and (at least traditionally, I don't know if this is improved), they aren't given much environment when they start - you can be caught out by a lack of 'PATH' for example.

Your repository will have example batchfile/shell-script hooks in the 'hooks' directory, but I've also written them in C# in the past.

This http://wordaligned.org/articles/a-subversion-pre-commit-hook looks like a good general introduction to pre-commit hooks.

Magnus answered 24/11, 2008 at 11:48 Comment(0)
M
1

No, To get information about the transaction your script can simply query svn about the details. And svn can provide that information, it need not be on the same server.

What he means is that when subversion executes your hook it runs w/o an environment and by the svn server itself. Any external resources your svn hook might need have to be accessible by the svn server account. From what you are asking this may not be a problem, assuming you don't need some sort of external database access or the like for you to compare the transaction against.

Your best bet is to look at some of the subversion hooks that come with svn for examples. Also SVN Hook Arguments lists how each hook is called.

Mozell answered 24/11, 2008 at 12:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.