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( ...@@ -24,6 +24,7 @@ $getopt = new Getopt(array(
array('v', 'version', Getopt::NO_ARGUMENT, 'Just shows the version') array('v', 'version', Getopt::NO_ARGUMENT, 'Just shows the version')
)); ));
$issue_mapping = [];
try { try {
$getopt->parse(); $getopt->parse();
...@@ -55,11 +56,11 @@ try { ...@@ -55,11 +56,11 @@ try {
$migration = new Migration($getopt->getOption('gitlab'), $getopt->getOption('token'), $getopt->getOption('admin'), $getopt->getOption('trac'), $getopt->getOption('link'), $userMapping); $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 we have a component, migrate it
if (!is_null($getopt->getOption('component'))) { 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 we have a custom query, migrate it
if (!is_null($getopt->getOption('query'))) { 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) { } catch (UnexpectedValueException $e) {
echo "Error: ".$e->getMessage()."\n"; echo "Error: ".$e->getMessage()."\n";
......
...@@ -43,7 +43,7 @@ class Migration ...@@ -43,7 +43,7 @@ class Migration
*/ */
public function migrateComponent($tracComponentName, $gitLabProject) { public function migrateComponent($tracComponentName, $gitLabProject) {
$openTickets = $this->trac->listOpenTicketsForComponent($tracComponentName); $openTickets = $this->trac->listOpenTicketsForComponent($tracComponentName);
$this->migrate($openTickets, $gitLabProject); return $this->migrate($openTickets, $gitLabProject);
} }
/** /**
...@@ -54,7 +54,7 @@ class Migration ...@@ -54,7 +54,7 @@ class Migration
*/ */
public function migrateQuery($tracQuery, $gitLabProject) { public function migrateQuery($tracQuery, $gitLabProject) {
$openTickets = $this->trac->listTicketsForQuery($tracQuery); $openTickets = $this->trac->listTicketsForQuery($tracQuery);
$this->migrate($openTickets, $gitLabProject); return $this->migrate($openTickets, $gitLabProject);
} }
/** /**
...@@ -93,6 +93,7 @@ class Migration ...@@ -93,6 +93,7 @@ class Migration
* @param string $gitLabProject GitLab project in which the issues should be created * @param string $gitLabProject GitLab project in which the issues should be created
*/ */
private function migrate($openTickets, $gitLabProject) { private function migrate($openTickets, $gitLabProject) {
$mapping = [];
foreach($openTickets as $ticket) { foreach($openTickets as $ticket) {
$originalTicketId = $ticket[0]; $originalTicketId = $ticket[0];
$title = $ticket[3]['summary']; $title = $ticket[3]['summary'];
...@@ -115,6 +116,8 @@ class Migration ...@@ -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"; 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 there are comments on the ticket, create notes on the issue
/*if (is_array($ticket[4]) && count($ticket[4])) { /*if (is_array($ticket[4]) && count($ticket[4])) {
foreach($ticket[4] as $comment) { foreach($ticket[4] as $comment) {
...@@ -126,6 +129,7 @@ class Migration ...@@ -126,6 +129,7 @@ class Migration
echo "\tAlso created " . count($ticket[4]) . " note(s)\n"; 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.
Please register or to comment