Blog

How conjoon migrated quickly from Trac to JIRA

Posted by:

How conjoon migrated quickly from Trac to JIRA

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

Do a checkout of your repository. Use the file-Protocol for performance reason.


console:/# svn log -v --xml > logfile.log

Next, fetch all the log-information out of the working copy, and save it to a file.


<?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);
        }
    }
}

I used this PHP snippet to transform the xml data to individual files, each holding the commit message for the revision indicated by the file name. If you want to use this script, make sure you're setting the path variables and the number of tickets to appropriate values.


<?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");
    }
}

After all messages were collected and the old Trac style ticket number was replaced with the Jira ticket numbers, I ran this script, which simply loops over the available files and calls svnadmin to replace the commit message with the one found in the file.


Before you intend to change your commit messages, please make sure you read and understand “changing SVN log messages“.

2


About the Author

Thorsten is the author of the conjoon open source project and the Ext.ux.Livegrid component. In this blog he writes more or less frequently about his current projects and web development in general.

Discussion

  1. Tobias Uhlig  November 10, 2011

    Hi Thorsten,

    great job! When are you moving forward to git & github instead of svn?

    Best regards
    Tobi

    (reply)

Add a Comment


Refresh