Generating a change log from SVN

At my workplace, for the project that I'm working on, we have 2 build processes. The first builds the solution whenever anyone checks in. The second is manually initiated to produce an MSI for the testing team - we push the button on this everytime there are significant changes and we want a testing release.

We thought it would be nice to generate a change log for the testers so that they could know what we'd committed since the last test release - because not all changes have supporting documentation ;-)

So, what we needed to do was:
1) Retrieve the number of the revision before the last release to testing
2) Pull down all the commit messages between that revision and the HEAD
3) Transform the resulting xml into an easy to read change log
4) Save the number of the latest revision for next time (i.e. to be used in step 1 next time)

Googling around didn't turn up much of use, although we did find David Whitney's Changelog Generator written in C#. Although we ultimately chose not to use this solution kudos to David - we've 'borrowed' some of the templates in his ChangeLog.xsl!

So to accompish points 1-4 here's what we came up with. Essentially it's all SVN.exe automation using NAnt, with a cheeky bit of XSLT in the middle.

1) Read the last release revision number from a previously dropped file:

<target name="ReadLastRevisionNumberFromDisk">
<xmlpeek file="LastRevision.xml" xpath="/info/entry/@revision" property="previous.revision"/>
</target>


2) Pull the commit messages out of SVN from that revision to HEAD:

<target name="PullDownLog" depends="ReadLastRevisionNumberFromDisk">
<exec program="C:\Program Files\CollabNet Subversion Server\SVN.exe" output="svnlog.xml">
<arg line=" --verbose --xml -r HEAD:${previous.revision} log ${repository}"/>
</exec>
</target>


3) Transform the resulting XML into an appealing change log format:

<target name="TransformIntoChangeLog" depends="PullDownLog">
<style style="D:\Build\SvnToChangeLog.xslt" in="svnlog.xml" out="${publish.path}\changelog.txt"/>
</target>


4) Save the HEAD revision number for retrieval in step 1 next time:

<target name="SaveLastRevisiontoDisk" depends="TransformIntoChangeLog">
<exec program="C:\Program Files\CollabNet Subversion Server\SVN.exe" output="LastRevision.xml">
<arg line=" --xml -r HEAD info ${repository}"/>
</exec>
</target>


And voilĂ  - that's it. Now everytime we create a build for the test team they get a changelog too! Of course, whether they read it is a different story...

Comments