<p>What kinds of hook scripts are people using for Subversion? Just general ideas but code would be great too!</p>

[{'answer_id': 6165, 'author': 'Mark Renouf', 'author_id': 758, 'author_profile': 'https://Stackoverflow.com/users/758', 'pm_score': 0, 'selected': False, 'text': "<p>The most common one I think is to allow people to change revision comments after comitting. </p>\n\n<p>You need to enable the 'pre-revprop-change' hook script to allow that. The example provided, if enabled allows editing only the comment property and only be the original comitter. Great for correcting typos.</p>\n"}, {'answer_id': 6296, 'author': 'abyx', 'author_id': 573, 'author_profile': 'https://Stackoverflow.com/users/573', 'pm_score': 2, 'selected': False, 'text': "<p>In my work place we've set up a post-commit hook that generates RSS feeds that are displayed in various dash boards and are used for code reviewers to know when it is time to review and for us to see that new employees are committing enough.</p>\n"}, {'answer_id': 6359, 'author': 'Matt Miller', 'author_id': 763, 'author_profile': 'https://Stackoverflow.com/users/763', 'pm_score': 1, 'selected': False, 'text': '<p>I\'m using post-commit hooks (<a href="http://lincolnloop.com/blog/2007/may/04/basecamp-svn-integration/" rel="nofollow noreferrer">I think it\'s this one</a>) to post a message to a forum on Basecamp for each commit. Two advantages:</p>\n\n<ol>\n<li><p>As the lead developer, I get a roll-up of commits every morning (via the RSS feed from that basecamp forum) and can see what my team has been up to pretty quickly.</p></li>\n<li><p>Our Trac/SVN install is behind our firewall, so this gives my higher-ups in other locations a window into what we\'re doing. They might not understand it, but to a manager a lot of activity looks like, well, a lot of activity ;)</p></li>\n</ol>\n\n<p>I guess the end result of this is similar to what @Aviv is doing.</p>\n\n<p>I\'m looking into solutions for building the latest commit on a separate server for continuous integration, but I\'m going to have to change the way we make changes to our database schema before that will work.</p>\n'}, {'answer_id': 9532, 'author': 'kauppi', 'author_id': 964, 'author_profile': 'https://Stackoverflow.com/users/964', 'pm_score': 0, 'selected': False, 'text': '<p>A hook to notify the bug/issue management system of changes to repository. Ie. the commit message has issue:546 or similar tag in it that is parsed and fed to the bug management system.</p>\n'}, {'answer_id': 27003, 'author': 'Sir Rippov the Maple', 'author_id': 2822, 'author_profile': 'https://Stackoverflow.com/users/2822', 'pm_score': 0, 'selected': False, 'text': '<p>We check the following with our hook scripts:</p>\n\n<ul>\n<li>That a commit log message has been supplied</li>\n<li>That a reviewer has been specified for the commit</li>\n<li>That no automatically generated code or banned file types land up in the repository</li>\n<li>Send an email out when a branch / tag is created</li>\n</ul>\n\n<p>We still want to implement the following:</p>\n\n<ul>\n<li>Send an email when a user acquires a lock on a file</li>\n<li>Send an email when your lock has been stolen</li>\n<li>Send an email to everyone when a revision property has been changed</li>\n</ul>\n'}, {'answer_id': 29219, 'author': 'Thomas Vander Stichele', 'author_id': 2900, 'author_profile': 'https://Stackoverflow.com/users/2900', 'pm_score': 2, 'selected': False, 'text': '<p>several things we use them for:</p>\n\n<ul>\n<li>integrating with the bug tracker (<a href="http://trac.edgewall.org/" rel="nofollow noreferrer">Trac in our case</a> - a commit message that says \'Closes #514\' automatically marks that bug as closed</li>\n<li>integrating with the build integration (<a href="http://buildbot.net/" rel="nofollow noreferrer">buildbot in our case</a> - a commit to a watched branch triggers a build</li>\n<li>pre-commit hook for validating the commit - we use <a href="http://svnchecker.tigris.org/" rel="nofollow noreferrer">svnchecker</a>.  It validates our Python code for <a href="http://www.python.org/dev/peps/pep-0008/" rel="nofollow noreferrer">PEP8 correctness</a></li>\n<li>sending checkin mails to a mailing list</li>\n<li>running indentation scripts</li>\n</ul>\n'}, {'answer_id': 30649, 'author': 'Nathan Black', 'author_id': 3265, 'author_profile': 'https://Stackoverflow.com/users/3265', 'pm_score': 3, 'selected': False, 'text': '<p>We use <a href="http://www.fogcreek.com/FogBugz/" rel="nofollow noreferrer">FogBugz</a> for bug tracking, it provides subversion commit scripts that allow you to include a case number in your check in comments and then associates the bug with the check in that fixed it. It does require a <a href="http://websvn.tigris.org/" rel="nofollow noreferrer">WebSVN</a> instance to be set up so that you have a web based viewer for your repository.</p>\n'}, {'answer_id': 44773, 'author': 'Johan Lübcke', 'author_id': 4220, 'author_profile': 'https://Stackoverflow.com/users/4220', 'pm_score': 0, 'selected': False, 'text': '<p>We use a commit hook script to trigger our release robot. Writing new release information to a file named changes.txt in our different products will trigger the creation of a tag and the relevant artifacts.</p>\n'}, {'answer_id': 44815, 'author': 'jonezy', 'author_id': 2272, 'author_profile': 'https://Stackoverflow.com/users/2272', 'pm_score': 0, 'selected': False, 'text': "<p>I have one setup using the Ruby Tinder library that I send to a campfire room, if anyone wants the script I can post or send the code to you.</p>\n\n<p>Other common ones I've seen are posts to bug tracking systems and email notifications.</p>\n"}, {'answer_id': 44858, 'author': 'Troels Arvin', 'author_id': 4462, 'author_profile': 'https://Stackoverflow.com/users/4462', 'pm_score': 3, 'selected': False, 'text': '<p>If you have a mix of unix and Windows users working with the repository, I urge you to use the <em><a href="http://svn.apache.org/viewvc/subversion/trunk/contrib/hook-scripts/case-insensitive.py?view=markup" rel="nofollow noreferrer">case-insensitive.py</a></em> pre-commit hook-script as a precautionary measure. It prevents hard-to-sort-out situations where svn <a href="http://subversion.apache.org/faq.html#case-change" rel="nofollow noreferrer">updates fail for Windows users because of a file rename which only changed the case of the file name</a>. Believe me, there is a good chance it will save you trouble.</p>\n'}, {'answer_id': 53793, 'author': 'clawrence', 'author_id': 5534, 'author_profile': 'https://Stackoverflow.com/users/5534', 'pm_score': 1, 'selected': False, 'text': '<p>This was discussed on the subversion users mailing list a while ago. <a href="http://svn.haxx.se/users/archive-2008-07/0779.shtml" rel="nofollow noreferrer">This</a> post in particular has some useful ideas.</p>\n'}, {'answer_id': 68850, 'author': 'Philibert Perusse', 'author_id': 7984, 'author_profile': 'https://Stackoverflow.com/users/7984', 'pm_score': 6, 'selected': False, 'text': '<p>I am using the <code>pre-revprop-change</code> hook that allows me to actually go back and edit comments and such information after the commit has been performed. This is very useful if there is missing/erroneous information in the commit comments.</p>\n\n<p>Here I post a <code>pre-revprop-change.bat</code> batch file for Windows NT or later. You\ncan certainly enhance it with more modifications. You can also derive a\n<code>post-revprop-change.cmd</code> from it to back up the old <code>snv:log</code> somewhere or just to append it to the new log.</p>\n\n<p>The only tricky part was to be able to actually parse the stdin from\nthe batch file. This is done here with the <code>FIND.EXE</code> command.</p>\n\n<p>The other thing is that I have had reports from other users of issues with the use of the <code>/b</code> with the <code>exit</code> command. You may just need to remove that <code>/b</code> in your specific application if error cases do not behave well.</p>\n\n<pre><code>@ECHO OFF\n\nset repos=%1\nset rev=%2\nset user=%3\nset propname=%4\nset action=%5\n\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: Only allow changes to svn:log. The author, date and other revision\n:: properties cannot be changed\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\nif /I not \'%propname%\'==\'svn:log\' goto ERROR_PROPNAME\n\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: Only allow modifications to svn:log (no addition/overwrite or deletion)\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\nif /I not \'%action%\'==\'M\' goto ERROR_ACTION\n\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: Make sure that the new svn:log message contains some text.\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\nset bIsEmpty=true\nfor /f "tokens=*" %%g in (\'find /V ""\') do (\n set bIsEmpty=false\n)\nif \'%bIsEmpty%\'==\'true\' goto ERROR_EMPTY\n\ngoto :eof\n\n\n\n:ERROR_EMPTY\necho Empty svn:log properties are not allowed. &gt;&amp;2\ngoto ERROR_EXIT\n\n:ERROR_PROPNAME\necho Only changes to svn:log revision properties are allowed. &gt;&amp;2\ngoto ERROR_EXIT\n\n:ERROR_ACTION\necho Only modifications to svn:log revision properties are allowed. &gt;&amp;2\ngoto ERROR_EXIT\n\n:ERROR_EXIT\nexit /b 1 \n</code></pre>\n'}, {'answer_id': 3630318, 'author': 'Philibert Perusse', 'author_id': 7984, 'author_profile': 'https://Stackoverflow.com/users/7984', 'pm_score': 0, 'selected': False, 'text': '<p>Windows pre-commit hook to check that log contains something.</p>\n\n<pre><code>@ECHO OFF\nsetlocal\n\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: Get subversion arguments\nset repos=%~1\nset txn=%2\n\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: Set some variables\nset svnlookparam="%repos%" -t %txn%\n\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: Make sure that the new svn:log message contains some text.\nset bIsEmpty=true\nfor /f "tokens=* usebackq" %%g in (`svnlook log %svnlookparam%`) do (\n   set bIsEmpty=false\n)\nif \'%bIsEmpty%\'==\'true\' goto ERROR_EMPTY\n\necho Allowed. &gt;&amp;2\n\ngoto :END\n\n\n:ERROR_EMPTY\necho Empty log messages are not allowed. &gt;&amp;2\ngoto ERROR_EXIT\n\n:ERROR_EXIT\n:: You may require to remove the /b below if your hook is called directly by subversion\nexit /b 1\n\n:END\nendlocal\n</code></pre>\n'}, {'answer_id': 3630534, 'author': 'Philibert Perusse', 'author_id': 7984, 'author_profile': 'https://Stackoverflow.com/users/7984', 'pm_score': 1, 'selected': False, 'text': '<p>post-commit hook to send email notification that something changed in the repository to a list of emails. You need <a href="http://glob.com.au/sendmail/" rel="nofollow noreferrer">sendmail.exe</a> in the same folder than your hook file, along with sendmail.ini.</p>\n\n<p>You also need a file post-commit.tos.txt next to your post-commit.cmd to list the mail recipients. The file should contain:</p>\n\n<pre><code>user1@example.com,user2@example.com,user3@example.com\n</code></pre>\n\n<p>Here is the hook code:</p>\n\n<pre><code>@ECHO OFF\nsetlocal\n\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: Get subversion arguments\nset repos=%~1\nset rev=%2\n\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: Set some variables\nset tos=%repos%\\hooks\\%~n0.tos.txt\nset reposname=%~nx1\nset svnlookparam="%repos%" --revision %rev%\n\nif not exist "%tos%" goto :END\n\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: Prepare sendmail email file\nset author=\nfor /f "tokens=* usebackq" %%g in (`svnlook author %svnlookparam%`) do (\n  set author=%%g\n)\n\nfor /f "tokens=* usebackq delims=" %%g in ("%tos%") do (\n  set EmailNotificationTo=%%g\n)\nset SendMailFile=%~n0_%reposname%_%rev%.sm\n\necho To: %EmailNotificationTo% &gt;&gt; "%SendMailFile%"\necho From: %reposname%.svn.technologie@gsmprjct.com &gt;&gt; "%SendMailFile%"\necho Subject: [%reposname%] Revision %rev% - Subversion Commit Notification  &gt;&gt; "%SendMailFile%"\n\necho --- log [%author%] --- &gt;&gt; "%SendMailFile%"\nsvnlook log %svnlookparam% &gt;&gt; "%SendMailFile%" 2&gt;&amp;1\necho --- changed --- &gt;&gt; "%SendMailFile%"\nsvnlook changed %svnlookparam% --copy-info &gt;&gt; "%SendMailFile%" 2&gt;&amp;1\n\necho .&gt;&gt; "%SendMailFile%"\n\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: Send email\ntype "%SendMailFile%" | "%~dp0sendmail.exe" -t\n\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n:: Clean-up\nif exist "%SendMailFile%" del "%SendMailFile%"\n\n\n:END\nendlocal\n</code></pre>\n'}, {'answer_id': 7303568, 'author': 'JohnUlmer', 'author_id': 928175, 'author_profile': 'https://Stackoverflow.com/users/928175', 'pm_score': 0, 'selected': False, 'text': '<p>I forgot to enter a comment while committing. Didn\'t have time to figure out why my pre-revprop-change hook wasn\'t working. So the following svnadmin command worked for me to enter a commit message: \n    <code>svnadmin setlog &lt;filesystem path to my repository&gt; --bypass-hooks -r 117 junk</code>,\nwhere "junk" is the file containing the text which I wanted to be the comment. <code>svn setlog help</code> has more usage info...</p>\n'}, {'answer_id': 9010360, 'author': 'nicobo', 'author_id': 579827, 'author_profile': 'https://Stackoverflow.com/users/579827', 'pm_score': 2, 'selected': False, 'text': '<p>For those who are looking for a pre-revprop-change.bat for a <strong>snvsync</strong> operation :</p>\n\n<p><a href="https://gist.github.com/1679659" rel="nofollow">https://gist.github.com/1679659</a></p>\n\n<pre><code>@ECHO OFF\n\nset user=%3\n\nif /I \'%user%\'==\'syncuser\' goto ERROR_REV\n\nexit 0\n\n:ERROR_REV echo "Only the syncuser user may change revision properties" &gt;&amp;2\nexit 1\n</code></pre>\n\n<p>It just comes from here : <a href="http://chestofbooks.com/computers/revision-control/subversion-svn/Repository-Replication-Reposadmin-Maint-Replication.html" rel="nofollow">http://chestofbooks.com/computers/revision-control/subversion-svn/Repository-Replication-Reposadmin-Maint-Replication.html</a> and has been adapted for Windows.</p>\n'}]
['https://Stackoverflow.com/questions/6155', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/204/']