<?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>zoe.vc &#187; windows</title>
	<atom:link href="http://www.zoe.vc/tag/windows/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zoe.vc</link>
	<description>development &#38; freelancing blog</description>
	<lastBuildDate>Mon, 30 Jan 2012 07:03:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Bug Genie 2 SVN Integration on Windows with VisualSVN Server</title>
		<link>http://www.zoe.vc/2009/the-bug-genie-2-svn-integration-on-windows-with-visualsvn-server/</link>
		<comments>http://www.zoe.vc/2009/the-bug-genie-2-svn-integration-on-windows-with-visualsvn-server/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 15:02:31 +0000</pubDate>
		<dc:creator>Alex (zoe.vc)</dc:creator>
				<category><![CDATA[Bugtracker]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[bugs2]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[svn_integration]]></category>
		<category><![CDATA[thebuggenie]]></category>
		<category><![CDATA[visualsvn]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.zoe.vc/?p=93</guid>
		<description><![CDATA[In my local development environment at home I use The Bug Genie 2 for bugtracking. The tool is quiet cool, although the german translation is totally broken (I fixed it and send it to them, let's see what happens). It comes with a module called "svn_integration" for integrating SVN into the tracker to automatically have [...]]]></description>
			<content:encoded><![CDATA[<p>In my local development environment at home I use <a href="http://www.thebuggenie.com/">The Bug Genie 2</a> for bugtracking. The tool is quiet cool, although the german translation is totally broken (I fixed it and send it to them, let's see what happens). It comes with a module called "svn_integration" for integrating SVN into the tracker to automatically have updated issues when the SVN comments contain special keywords. That's quiet cool, too, but unfortunatly does not work for me.</p>
<p>I'm using Windows Vista Business x64 as os and for SVN the wonderful, free and easy <a href="http://www.visualsvn.com/server/">VisualSVN Server</a>. Next ugly thing on The Bug Genie is that there is no documentation for the modules. I found an <a href="http://www.thebuggenie.com/forum/viewtopic.php?f=4&amp;t=30">entry in the forums</a> how to use the integration in windows, but that did not work out of the box. But the code is already within the module, what is good.</p>
<p>So open <strong>modules/svn_integration/post_commit.php </strong>from your buggenie installation directory and adjust this line with your path to the bugtracker installation dir:</p>
<pre class="php"><a href="http://www.php.net/define"><span style="color: #000066;">define</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'BUGS2_INCLUDE_PATH'</span>, <span style="color: #ff0000;">'D:<span style="color: #000099; font-weight: bold;">\\</span>xampp<span style="color: #000099; font-weight: bold;">\\</span>htdocs<span style="color: #000099; font-weight: bold;">\\</span>bugs<span style="color: #000099; font-weight: bold;">\\</span>'</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p>Then create a batch file in the same directory called <strong>post-commit.bat</strong>. You can see the source below, copy it and adjust the following variables. I used the code from the forum post and adjusted it a little. Remember that urls with whitespaces do not work, create a symlink or rename your directories:</p>
<ul>
<li>Path to svnlook.exe (you see my VisualSVN Server resides in <em>D:\VisualSVN_Server</em>, the default location <em>C:\Program Files (x86)\VisualSVN Server</em> does not work because of the whitespaces) VisualSVN Server has all the svn tools in its <strong>bin</strong> directory.</li>
</ul>
<pre>SET SVNLOOK=D:\VisualSVN_Server\bin\svnlook.exe</pre>
<ul>
<li>The path to your php executable. I used XAMPP, so it is in <strong>D:\xampp\php\php.exe</strong> if installed in root on drive D.</li>
</ul>
<pre>SET PHP=D:\xampp\php\php.exe</pre>
<ul>
<li>The path to your SVN directory. This is where svn stores its data.</li>
</ul>
<pre>SET SVN_PATH=D:\svn\</pre>
<ul>
<li>The post-commit hook we create later takes two arguments from VisualSVN Server, the path and the revision. Unfortunatly VisualSVN Server uses the url as path which collides with the svnlook command we use to determine if a bug was mentioned in a revision comment, as svnlook wants the real file path.<br />
So we have to adjust the url to a path. As there is no real substring functionality for windows batch (or I did not search long enough) we simply count the length of our SVN url. In my case VisualSVN Server listens at <em>https://amanda:8443/svn/</em>, so a repository would be at <em>https://amanda:8443/svn/my_repos</em>. The server root (<em>https://amanda:8443/svn/) </em>has a length  length of 24. Change the 24 to the length of your url. The batch then combines the SVN_PATH and your repository path to the local path, <em>D:\svn\myrepos</em> in my case here.</li>
</ul>
<pre>SET REPOS=%REPOS:~24%</pre>
<ul>
<li>Once again, set the path to your installation directory of the bugtracker (replace <em>D:\xampp\htdocs\bugs</em> with your path):</li>
</ul>
<pre>%PHP% -f "D:\xampp\htdocs\bugs\modules\svn_integration\post-commit.php" "%AUTHOR%" "%REV%" "%COMMIT_MSG%" "%CHANGED%"</pre>
<p>After your saved the file, open VisualSVN Server and the properties of your repository. Select the the <strong>Hooks</strong> tab and doubleclick the <strong>Post-commit hook</strong>. Enter the path to the batch file with the 2 arguments path and revision, in my case I entered "<strong>D:\xampp\htdocs\bugs\modules\svn_integration\post-commit.bat %1 %2</strong>", where %1 is the repository path and %2 the revision number.</p>
<p>Finally you have to install either <a href="http://websvn.tigris.org/">WebSVN</a> (which I prefer) or <a href="http://www.viewvc.org/">ViewVC</a> and specify the path to your repository (in my case it is <em>http://localhost/websvn/listing.php?repname=my_repos&amp;</em>) in The Bug Genie module settings for svn_integration.</p>
<p><span style="text-decoration: underline;"><strong>One final and important hint:</strong></span> your user in the bugtracker has to have the same username as in SVN. By default, the first user in the tracker has the username "Administrator". My SVN user does not have the name "Administrator", so I logged out of the tracker, changed the property "<strong>uname</strong>" of the MySQL table "<strong>bugs2_users</strong>" for the admin to my SVN username, logged in and then everything worked fine.</p>
<p>As always, feel free to add comments and spread the word</p>
<p>And here the post-commit.bat code:</p>
<pre>@echo off
SET REV=%2
SET REPOS=%1

REM path to svnlook (remember that paths with whitespace do not work e.g. C:\Program Files --&gt; use mklink to create a path without)
SET SVNLOOK=D:\VisualSVN_Server\bin\svnlook.exe

REM path to php executable
SET PHP=D:\xampp\php\php.exe

REM path to svn (not url!)
SET SVN_PATH=D:\svn\

REM maps the svn url to the svn path - straightforward but the easiest way
REM replace with the length of your svn url e.g. 24 for https://amanda:8443/svn/
SET REPOS=%REPOS:~24%

SET REPOS=%SVN_PATH%%REPOS:/=\%

%SVNLOOK% log -r %REV% "%REPOS%" &gt; COMMIT_MSG
REM SET THE COMMIT_MSG FROM THE FILE. The file is expected to contain only one line with this value
FOR /F "delims=" %%A IN (COMMIT_MSG) DO SET COMMIT_MSG=%%A
echo COMMIT_MSG=%COMMIT_MSG%

%SVNLOOK% changed -r %REV% "%REPOS%" &gt; CHANGED
REM SET THE CHANGED FROM THE FILE. The file is expected to contain only one line with this value
FOR /F %%A IN (CHANGED) DO SET CHANGED=%%A
echo COMMIT_MSG=%CHANGED%

%SVNLOOK% author -r %REV% "%REPOS%" &gt; AUTHOR
REM SET THE AUTHOR FROM THE FILE. The file is expected to contain only one line with this value
FOR /F %%A IN (AUTHOR) DO SET AUTHOR=%%A
echo COMMIT_MSG=%AUTHOR%

%PHP% -r "echo urlencode($argv[1]);" "%COMMIT_MSG%" &gt; URL_COMMIT_MSG
REM SET THE URL_COMMIT_MSG FROM THE FILE. The file is expected to contain only one line with this value
FOR /F %%A IN (URL_COMMIT_MSG) DO SET URL_COMMIT_MSG=%%A
echo COMMIT_MSG=%URL_COMMIT_MSG%

%PHP% -f "D:\xampp\htdocs\bugs\modules\svn_integration\post-commit.php" "%AUTHOR%" "%REV%" "%COMMIT_MSG%" "%CHANGED%"</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.zoe.vc/2009/the-bug-genie-2-svn-integration-on-windows-with-visualsvn-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

