Skip to content
Snippets Groups Projects
Commit 56f9f4ed authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

get ticket/issue mapping from migration, re #2

parent 6331feeb
No related branches found
No related tags found
No related merge requests found
{
"gitlab-access-token": "se7cRwBAyySpFnzWmk7a"
}
......@@ -24,6 +24,7 @@ $getopt = new Getopt(array(
array('v', 'version', Getopt::NO_ARGUMENT, 'Just shows the version')
));
$issue_mapping = [];
try {
$getopt->parse();
......@@ -55,11 +56,11 @@ try {
$migration = new Migration($getopt->getOption('gitlab'), $getopt->getOption('token'), $getopt->getOption('admin'), $getopt->getOption('trac'), $getopt->getOption('link'), $userMapping);
// If we have a component, migrate it
if (!is_null($getopt->getOption('component'))) {
$migration->migrateComponent($getopt->getOption('component'), $getopt->getOption('project'));
$issue_mapping = $migration->migrateComponent($getopt->getOption('component'), $getopt->getOption('project'));
}
// If we have a custom query, migrate it
if (!is_null($getopt->getOption('query'))) {
$migration->migrateQuery($getopt->getOption('query'), $getopt->getOption('project'));
$issue_mapping = $migration->migrateQuery($getopt->getOption('query'), $getopt->getOption('project'));
}
} catch (UnexpectedValueException $e) {
echo "Error: ".$e->getMessage()."\n";
......
......@@ -43,7 +43,7 @@ class Migration
*/
public function migrateComponent($tracComponentName, $gitLabProject) {
$openTickets = $this->trac->listOpenTicketsForComponent($tracComponentName);
$this->migrate($openTickets, $gitLabProject);
return $this->migrate($openTickets, $gitLabProject);
}
/**
......@@ -54,7 +54,7 @@ class Migration
*/
public function migrateQuery($tracQuery, $gitLabProject) {
$openTickets = $this->trac->listTicketsForQuery($tracQuery);
$this->migrate($openTickets, $gitLabProject);
return $this->migrate($openTickets, $gitLabProject);
}
/**
......@@ -93,6 +93,7 @@ class Migration
* @param string $gitLabProject GitLab project in which the issues should be created
*/
private function migrate($openTickets, $gitLabProject) {
$mapping = [];
foreach($openTickets as $ticket) {
$originalTicketId = $ticket[0];
$title = $ticket[3]['summary'];
......@@ -115,6 +116,8 @@ class Migration
echo 'Created a GitLab issue #' . $issue['iid'] . ' for Trac ticket #' . $originalTicketId . ' : ' . $this->gitLab->getUrl() . '/' . $gitLabProject . '/issues/' . $issue['iid'] . "\n";
$mapping[$originalTicketId] = $issue['iid'];
// If there are comments on the ticket, create notes on the issue
/*if (is_array($ticket[4]) && count($ticket[4])) {
foreach($ticket[4] as $comment) {
......@@ -126,6 +129,7 @@ class Migration
echo "\tAlso created " . count($ticket[4]) . " note(s)\n";
}*/
}
return $mapping;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment