<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Geoff&#039;s Blog &#187; subversion</title>
	<atom:link href="http://blog.grimsy.net/tag/subversion/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.grimsy.net</link>
	<description>tech, travels and other stuff</description>
	<lastBuildDate>Wed, 06 Apr 2011 03:41:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>A few svn pre-commit hooks</title>
		<link>http://blog.grimsy.net/2008/07/a-few-svn-pre-commit-hooks/</link>
		<comments>http://blog.grimsy.net/2008/07/a-few-svn-pre-commit-hooks/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 01:34:00 +0000</pubDate>
		<dc:creator>Geoff Jacobs</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://grimsy.net/?p=22</guid>
		<description><![CDATA[I&#8217;ve recently been looking around for some pre-commit hooks for our subversion repositories. I figured that since I have them all up and running now, I might as well share them. I can&#8217;t remember where I got all of these from, so if it&#8217;s one of yours, then I apologise. Feel free to contact me [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently been looking around for some pre-commit hooks for our subversion repositories. I figured that since I have them all up and running now, I might as well share them.<br />
I can&#8217;t remember where I got all of these from, so if it&#8217;s one of yours, then I apologise. Feel free to contact me and I&#8217;ll give you credit for it.</p>
<p><span style="font-weight:bold;">Check for blank/empty commit messages and reject</span><br />
This goes in hooks/pre-commit</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">REPOS</span>=<span style="color: #ff0000;">&quot;$1&quot;</span><br />
<span style="color: #007800;">TXN</span>=<span style="color: #ff0000;">&quot;$2&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Make sure that the log message contains some text.</span><br />
<span style="color: #007800;">SVNLOOK</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">svnlook</span><br />
<span style="color: #007800;">SVNLOOKOK</span>=<span style="color: #000000;">1</span><br />
<span style="color: #007800;">$SVNLOOK</span> log <span style="color: #660033;">-t</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TXN</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$REPOS</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> \<br />
<span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;[a-zA-Z0-9]&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #007800;">SVNLOOKOK</span>=<span style="color: #000000;">0</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$SVNLOOKOK</span> = <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> Empty log messages are not allowed. Please provide a proper log message. <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">2</span><br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></div></div>
<p><span style="font-weight:bold;">Check that the commit message has a reference to a JIRA issue</span><br />
This goes in hooks/pre-commit, it also uses &#8216;check_log_message.sh&#8217; which can be found down further.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">REPOS</span>=<span style="color: #ff0000;">&quot;$1&quot;</span><br />
<span style="color: #007800;">TXN</span>=<span style="color: #ff0000;">&quot;$2&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Check log message for proper task/bug identification</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</span> <span style="color: #800000;">${REPOS}</span><span style="color: #000000; font-weight: bold;">/</span>hooks<span style="color: #000000; font-weight: bold;">/</span>check_log_message.sh <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
<span style="color: #800000;">${REPOS}</span><span style="color: #000000; font-weight: bold;">/</span>hooks<span style="color: #000000; font-weight: bold;">/</span>check_log_message.sh <span style="color: #ff0000;">&quot;<span style="color: #007800;">${REPOS}</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TXN}</span>&quot;</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></div></div>
<p><span style="font-style:italic;">check_log_message.sh</span></p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/bash</span><br />
<br />
<span style="color: #007800;">REPOS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${1}</span>&quot;</span><br />
<span style="color: #007800;">TXN</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${2}</span>&quot;</span><br />
<br />
<span style="color: #007800;">SVNLOOK</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">svnlook</span><br />
<br />
<span style="color: #007800;">LOG_MSG_LINE1</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #800000;">${SVNLOOK}</span> log <span style="color: #660033;">-t</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TXN}</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${REPOS}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> -n1<span style="color: #000000; font-weight: bold;">`</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG_MSG_LINE1}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #ff0000;">'^[a-zA-Z]+[-][1-9][0-9]*[:]?[\s]*.*$'</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null;<span style="color: #7a0874; font-weight: bold;">&#41;</span> \<br />
<span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG_MSG_LINE1}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #ff0000;">'^[nN][oO][jJ][iI][rR][aA][:]?[\s]*.*$'</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null;<span style="color: #7a0874; font-weight: bold;">&#41;</span> \<br />
<span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG_MSG_LINE1}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #ff0000;">'^\[maven-release-plugin\][\s]*.*$'</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null;<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">then</span><br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Your log message does not contain a JIRA Issue identifier (or bad format used)&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;The JIRA Issue identifier must be the first item on the first line of the log message.&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Proper JIRA format: &nbsp;'AAA-000'&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;JIRA regex: '^[a-zA-Z]+[-][1-9][0-9]*[:]?[\s]*.*$'&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">fi</span></div></div>
<p><span style="font-weight:bold;">Check that commit message is more than 5 characters long</span><br />
This goes in hooks/pre-commit</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">REPOS</span>=<span style="color: #ff0000;">&quot;$1&quot;</span><br />
<span style="color: #007800;">TXN</span>=<span style="color: #ff0000;">&quot;$2&quot;</span><br />
<br />
<span style="color: #007800;">SVNLOOK</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">svnlook</span><br />
<span style="color: #007800;">LOGMSG</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$SVNLOOK</span> log <span style="color: #660033;">-t</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TXN</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$REPOS</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>a-zA-Z0-<span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -c<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$LOGMSG</span>&quot;</span> <span style="color: #660033;">-lt</span> <span style="color: #000000;">5</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Please provide a meaningful comment when committing changes.&quot;</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000;">2</span><br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.grimsy.net/2008/07/a-few-svn-pre-commit-hooks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

