conjoon is currently being migrated to the Atlassian’s software suite: Jira, Confluence, Crowd, Fisheye… you name it. While the Trac importer that comes with Jira worked out of the box, I had to do some work to set all previously by Trac defined relations properly up. I also had to add dates to the ticket workflow by hand, but I’m pretty sure it was worth it: Jira is a powerful issue tracker and with all the integration points spread among the Atlassian software products each tool is plugged and connected to another one. Simply great if you want to do code reviews, create release notes, share content from the issue tracker with the confluence wiki and so on.
However, one last thing I wanted to do is to enable to show the source activity for all the tickets and revisions that were processed when we used Trac as our wiki/issue tracker. An easy task if you think about changing ticket relations within the database (i.e. transform #{TICKETNUMBER} to {PROJECTKEY}-{TICKETNUMBER}), but if you want to update the commit messages in the repository, too – it gets ugly. Or at least you’re in danger getting your hands dirty. Here’s what I did to change all the commit messages in conjoon’s repository to match Jira conventions:
console:/# svn co file:///repository
console:/# svn log -v --xml > logfile.log
<?php $file = "./logfile.log"; $dir = "./"; $xml = simplexml_load_string(file_get_contents($file)); $tickets = array(); for ($i = 0; $i < 1500; $i++) { $tickets['#'.$i] = 'CN-'.$i; } foreach ($xml as $tag => $data) { if ($tag == 'logentry') { $revision = $data->attributes()->revision; $msg = (string)$data->children()->msg; if (strpos($msg, '#') !== false) { $msg = str_replace(array_keys($tickets), array_values($tickets), $msg); file_put_contents($dir .'/r'.$revision, $msg); } } }
<?php for ($i = 0; $i < 1500; $i++) { $file = "./commits/r$i"; if (file_exists($file)) { exec("svnadmin setlog ./conjoon-rep --bypass-hooks -r $i $file"); } }
Before you intend to change your commit messages, please make sure you read and understand “changing SVN log messages“.