Pergunta

thank you for reading my question :)

My goal is to modify this message before a commit is fired to the SVN-Server:

enter image description here

I already have a start and pre-commit hook (C#), both of them are called when i try to commit something. I also have a working SharpSvn library. But unfortunately i'm not getting forward, I have no idea how to fill this message.

So is it possible and if yes, how? I'm glad about every little hint :)

Foi útil?

Solução

Commit hooks don't talk to the client except on a failure. Then, they send whatever was sent to Standard Error to the user. Hook scripts cannot change any aspect of the commit. (This isn't entirely true: A post-commit hook could modify the commit message, the author, and the commit time, but that's normally a really bad idea.)

What you can do is ensure your commit message is in the correct format, and then fail the commit if it isn't. It would be up to to user to resubmit their commit with the correct format.

I would not recommend using the built in TortoiseSVN client hooks. These are done on a machine-by-machine basis, so a user could opt out of them, and they don't work if the user uses a different client (such as the VisualStudio AnkhSVN plugin).

You didn't mention what you're trying to do or why.

You're more than welcome to use my hook written in Perl. The kitchen sink hook does several tasks, and one of them makes sure that the commit message is in the correct format. For example, you can require that it contains a defect tracking ID, or be at least ...say... 10 characters long.

However, if the user's commit message doesn't match the criteria, the hook will fail the commit, and the user will have to try again. The trick is to put a good error message, so the user knows what they did wrong. Believe me, after one or two tries, the users get the hang of what a good commit message needs to be.

However, you might want to try a slightly different route: Use a continuous integration system such as Jenkins.

What I've noticed is that as soon as I get a project up and running on Jenkins, the commit messages automatically improve. Each Subversion commit is turned into a build. But, Jenkins also shows you all the changes between the previous and current build and the commit message.

This mainly has to do with visibility. Before Jenkins, the commit messages are fairly hidden. You only see them if you did an svn log and few people ever do that on a regular basis. However, in Jenkins, you see it right there on each build and commit. You can see the history, who changed it, and what they changed via a few clicks on a webpage.

That might be the best way to handle what you want.

Outras dicas

Okay, I found an answer :)

It was wrong from me to try it via a hook-script. The better solution is building a custom issue tracker plugin:

http://tortoisesvn.googlecode.com/svn/trunk/contrib/issue-tracker-plugins/issue-tracker-plugins.txt

With this I can read my issues from DB, let the developer select the ones he need and put them into the log-message window.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top