tag:blogger.com,1999:blog-17669011698759157062024-03-19T12:34:45.211-05:00500Anonymoushttp://www.blogger.com/profile/14139094392605821584noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-1766901169875915706.post-9252164409305608242011-11-22T20:09:00.001-06:002011-11-29T10:13:25.950-06:00How to use git hooks to enforce relating commits to issues on githubRecently my team has been trying to take advantage of some of the issue and planning features github offers. We've been using github's issue tracking for a while and we really like how easy it is to tie commits to issues. We thought we could provide more visibility to the rest of our company and have smaller, more direct commits if we were more disciplined about tying commits to issues at commit time. <br />
<div>
<br /></div>
<div>
This is really easy to do using git hooks. Simply create a file named commit-msg in repo\.git\hooks and paste in the following code:</div>
<div>
<br /></div>
<div>
<div>
#!/bin/sh</div>
<div>
</div>
<div>
if git-rev-parse --verify HEAD >/dev/null 2>&1; then</div>
<div>
against=HEAD</div>
<div>
else</div>
<div>
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904</div>
<div>
fi</div>
<div>
if grep -i 'gh-[0-9]\+' $1 > /dev/null 2>&1; then</div>
<div>
exit 0</div>
<div>
else</div>
<div>
echo COMMIT REJECTED BY "commit-msg" HOOK:</div>
<div>
echo Commit log must close or mention a github issue \(use "closes GH-9999" or "mentions gh-9999"\)</div>
<div>
exit 1</div>
<div>
fi<br />
<br />
That will just make sure that gh-### appears in the commit message somewhere. If you need to commit something and it doesn't make sense to tie it to an issue, just add the --no-verify flag to the commit line. It's been working really well for us so far.</div>
</div>Anonymoushttp://www.blogger.com/profile/14139094392605821584noreply@blogger.com0tag:blogger.com,1999:blog-1766901169875915706.post-8364867266113120932009-04-22T15:20:00.015-05:002009-04-22T23:40:55.889-05:00Integrating Subversion with Axosoft OnTime<span style="color: rgb(0, 0, 0);font-size:100%;" ><span style="font-family:arial;">I've been meaning to sit down and get our ticket / bug tracker (Axosoft OnTime) integrated with our SCM tool (Subversion) for a while now. Today I finally ran out of excuses to keep putting it off. Having had a pleasant prior experience integrating Trac with Subversion, I wasn't expecting it to take too long. The real problem is the lack of information on the Internet about this subject. So, without further delay, here are the steps I went through to get our installation of OnTime and Subversion talking with each other.</span></span><br /><br /><span style="color: rgb(51, 51, 51); font-weight: bold;font-size:130%;" ><span style="font-family:arial;">Configure Source Control Management</span></span><br /><span style="font-family:arial;"><br /><span style="color: rgb(0, 0, 0);font-size:100%;" >The first thing you'll want to do is configure Source Control Management in OnTime. Right click on any of your projects (although I would suggest you do this from the root project) and select Manage Source Control. OnTime will then present you with the following screen:</span></span><br /><br /><a style="font-family: arial;" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQVuRLhJiWQQ_NgN9xVHmmvGWo_RpMLGDGE3aJp3VA4VxNNBFxou6DW4_agm1FntB7_zcF6hAqdbHsWLPlpp-gzruPnbi9nsT6FUGP1oNLH_isUmlk3I4k83qAWQVxPplUzG-3XvWeb5Q/s1600-h/SourceControlManagement.JPG"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 191px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQVuRLhJiWQQ_NgN9xVHmmvGWo_RpMLGDGE3aJp3VA4VxNNBFxou6DW4_agm1FntB7_zcF6hAqdbHsWLPlpp-gzruPnbi9nsT6FUGP1oNLH_isUmlk3I4k83qAWQVxPplUzG-3XvWeb5Q/s400/SourceControlManagement.JPG" alt="" id="BLOGGER_PHOTO_ID_5327620307052821842" border="0" /></a><ol style="font-family:arial;"><li style="color: rgb(0, 0, 0);"><span style="font-size:100%;">Set Subversion as your source control plug-in.</span></li><li style="color: rgb(0, 0, 0);"><span style="font-size:100%;">Command Line Client -- TortoiseSVN will not cut it. If you don't have a command line client installed (VisualSVN is fine), any of the ones <a href="http://subversion.tigris.org/getting.html#windows">here</a> will work. I have VisualSVN but I verified that the CollabNet one works as well. Enter the path to svn.exe.</span></li><li style="color: rgb(0, 0, 0);"><span style="font-size:100%;">Server URL -- This is the same value you use for your source repository. It's usually something like svn://host/repositoryName.</span></li><li style="color: rgb(0, 0, 0);"><span style="font-size:100%;">Username -- Your username in Subversion.</span></li><li style="color: rgb(0, 0, 0);"><span style="font-size:100%;">Password -- Your password for Subversion</span></li><li style="color: rgb(0, 0, 0);"><span style="font-size:100%;">Working Copy Location -- Location of the repository on your hard drive.</span></li><li style="color: rgb(0, 0, 0);"><span style="font-size:100%;">Timeout Value -- This one is important. It defaults to 15 seconds. If you have a slow Internet connection or you're working with a large repository you will likely need more time. If you get a null reference exception that isn't handled, increasing this value may resolve your problem.</span><br /></li></ol><span style="font-weight: bold;font-family:arial;" ><span style="color: rgb(51, 51, 51);font-size:130%;" >Configure Subversion Properties</span></span><br /><br /><span style="color: rgb(0, 0, 0);font-size:100%;" ><span style="font-family:arial;">Go to the subversion properties on the root folder in your re</span></span><span style="color: rgb(0, 0, 0);font-size:100%;" ><span style="font-family:arial;">pository and enter the following values:</span></span><span style="font-size:100%;"><br /></span><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkpzN7gQxYzyvGNSc24FaXa7e_PbhgFoZ7QZup1CAE15294bA9Tb7sT8keX4zf30X8H0wiIdXmPKa7aYE3uQlB_blRMlC-KD26gdPmlaJWEJzoE39OtVVQskPGqO8M-UXcFE5s3N_A1Ok/s1600-h/SubversionProperties.JPG"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 203px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkpzN7gQxYzyvGNSc24FaXa7e_PbhgFoZ7QZup1CAE15294bA9Tb7sT8keX4zf30X8H0wiIdXmPKa7aYE3uQlB_blRMlC-KD26gdPmlaJWEJzoE39OtVVQskPGqO8M-UXcFE5s3N_A1Ok/s400/SubversionProperties.JPG" alt="" id="BLOGGER_PHOTO_ID_5327693556790746674" border="0" /></a><br /><span style="color: rgb(0, 0, 0);font-size:100%;" ><span style="font-family:arial;">bugtraq:number false is actually important for the way I'm getting around a specific design choice with OnTime. All of the primary keys for tasks, defects, incidents, features seem to be shared across ticket types. In order to properly navigate to the ticket, we're going to adopt a naming convention to tell TortoiseLinker.asp what type of issue we're dealing with so it will know where to send us.</span><br /><br /><span style="font-family:arial;">When you enter the bug id on a code checkin, prefix the issue with a d for defect, t for task, and an f for feature.</span></span><br /><span style="font-family:arial;"><br /><span style="color: rgb(51, 51, 51); font-weight: bold;font-size:130%;" >Create TortoiseLinker.asp</span></span><span style="font-family:arial;"><br /><br /><span style="color: rgb(0, 0, 0);font-size:100%;" >Now that we've got our subversion variables setup, the only thing left is placing a script in your OnTime web app that will direct the user to the appropriate ticket.</span></span><span style="font-size:100%;"><br /></span><ol style="color: rgb(0, 0, 0);font-family:arial;"><li><span style="font-size:100%;">Create a file called TortoiseLinker.asp and put it in the root directory of your OnTime web application.</span></li></ol><span style="color: rgb(0, 0, 0);font-size:100%;" ><span style="font-family:arial;">My file has the following contents, it's quite possible you will need to modify this for your needs, but this should give you the general idea of what's going on here.</span></span><br /><span style="font-family:arial;"><pre style="border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); line-height: 14px; width: 100%;font-family:Andale Mono,Lucida Console,Monaco,fixed,monospace;font-size:12px;"><code><%<br /><span style="font-family:arial;">Dim urlid</span><br /><span style="font-family:arial;">Dim ticketType</span><br /><br /><br /><span style="font-family:arial;">'Set both of these values = to the bug id coming across</span><br /><span style="font-family:arial;">ticketType = request("id")</span><br /><span style="font-family:arial;">urlid = request("id")</span><br /><br /><span style="font-family:arial;">'Grab the first character. (d = defect, t = task, f = feature)</span><br /><span style="font-family:arial;">ticketType = left(ticketType, 1)</span><br /><br /><span style="font-family:arial;">Dim ticketTypeAsciiNumber</span><br /><br /><span style="font-family:arial;">'Get the ascii value of the first character</span><br /><span style="font-family:arial;">ticketTypeAsciiNumber = Asc(UCase(ticketType))</span><br /><br /><span style="font-family:arial;">'See if the ascii value of the first character equals d, f, or t</span><br /><span style="font-family:arial;">if(ticketTypeAsciiNumber = 68 or ticketTypeAsciiNumber = 70 or ticketTypeAsciiNumber = 84) Then</span><br /><span style="font-family:arial;"> 'Set the url to the actual bug number, ripping off the first character that indicates the issue type</span><br /><span style="font-family:arial;"> urlid = right(request("id"), len(request("id"))- 1)</span><br /><span style="font-family:arial;"> </span><br /><span style="font-family:arial;"> 'defect</span><br /><span style="font-family:arial;"> if(ticketTypeAsciiNumber = 68) then</span><br /><span style="font-family:arial;"> response.redirect("/OnTime2008Web/Defects/ViewDefect.aspx?DefectId=" + urlid)</span><br /><span style="font-family:arial;"> 'feature</span><br /><span style="font-family:arial;"> elseif(ticketTypeAsciiNumber = 70) then</span><br /><span style="font-family:arial;"> response.redirect("/OnTime2008Web/Features/ViewFeature.aspx?FeatureId=" + urlid)</span><br /><span style="font-family:arial;"> 'task</span><br /><span style="font-family:arial;"> elseif(ticketTypeAsciiNumber = 84) then</span><br /><span style="font-family:arial;"> response.redirect("/OnTime2008Web/Tasks/ViewTask.aspx?TaskId=" + urlid)</span><br /><span style="font-family:arial;"> 'should never really get here</span><br /><span style="font-family:arial;"> else</span><br /><span style="font-family:arial;"> response.redirect("/OnTime2008Web/Defects/ViewDefect.aspx?DefectId=" + urlid)</span><br /><span style="font-family:arial;"> end if</span><br /><span style="font-family:arial;">'the first number is something we don't support, just send them on to the defect page and hope for the best.</span><br /><span style="font-family:arial;">else</span><br /><span style="font-family:arial;"> response.redirect("/OnTime2008Web/Defects/ViewDefect.aspx?DefectId=" + urlid)</span><br /><span style="font-family:arial;">end if</span><br /><br /><span style="font-family:arial;">response.end</span><br /><span style="font-family:arial;">%></span><br /><span style="font-family:arial;"></span></code></pre></span><br /><span style="color: rgb(0, 0, 0);font-size:100%;" ><span style="font-family:arial;">Done! Now you can manually link files in OnTime to issues and you'll get links in the log messages from subversion that will take you directly to the issue in the web app. </span></span><span style="font-size:100%;"><br /><br /></span><span style="color: rgb(0, 0, 0);font-size:100%;" ><span style="font-family:arial;">One final note: I had to enable asp page processing on our server to get this to work. Directions on how to do that can be found </span><a style="font-family: arial;" href="http://technet.microsoft.com/en-us/library/cc737992.aspx">here</a><span style="font-family:arial;">.</span></span>Anonymoushttp://www.blogger.com/profile/14139094392605821584noreply@blogger.com3