开发者

Can I/should I update the commit message in an SVN pre-commit hook

I have added some pre commit hooks to my SVN repos that check that people are putting a JIRA item against every commit. This works fine.

However looking at the svn logs it would be nice to have the summary shown in the commit message otherwise it's just a bunch of numbers and you have to refer 开发者_开发百科back to JIRA all the time to see what's going on.

I therefore thought that rather than requiring people to put the summary in each time I could parse the commit message and tack the summary on as necessary. I can achieve this but I am not about two things

  • How can I change the commit message for a transaction in the hook?
  • There are big warnings in the SVN docs about altering transactions during pre-commit hooks. Does this apply to just changing the commit message?


Do not change a revision during a commit! This includes modifying files, modifying properties, or even the commit message. In fact, svnlook doesn't give you the ability to do such stuff and for good reason. There's a good chance that you could cause the commit to fail because you're attempting to munge the comment.

If you want to do this, at least use a post-commit trigger. That way, you have a revision number, and you can modify svn:log.

Even better is to have a crontab run a job to go through your Subversion log and modify the commit message. This way, you're not tying up the commit while waiting for your trigger to modify the commit message.

However, the best solution is to use Hudson as a continuous build server. Hudson will automatically build, run your tests, and even email the developers on build problems.

Hudson has a plugin that links to Jira. It will:

  • Add a comment to a Jira ticket whenever it does a build and detects that ticket in the comment. That way, you can look at a Jira ticket and see what build was involved with that ticket.
  • Hudson will display your commit messages with links to the Jira ticket that is involved. If a developer wants to see the details of a ticket, they can go to Hudson and click on the link.
  • (Nothing to do with Jira) Hudson also allows you to use ViewVC or Sventon as a source code browser. When you look at your changes in Hudson, it'll link to ViewVC or Sventon and show you the diffs in the files.


This applies on the commit message as well as the content cause you will loose the synchronization with your client. For the commit message that seemed to be not a big deal but i would recommend if the log message does not contain the needed information just decline the commit. Update: What you can do as well is to change the log messages later (via a job which scan's svn repo on time based), cause it's a revision property. But bear in mind the change of the log message is not logged anywhere...


I did this a few years ago with CVS and JIRA, then SVN and JIRA. Somehow, adding the bug info to the commit message seems wrong, so I modified the other tools that displayed the commit message to add the JIRA info when they were viewed. This also avoids having slow commits due to a transaction waiting for JIRA.

~Matt

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜