public function testConvertProjectLinks() { $markdown = toMarkdown('DDC-117 DBAL-123 DCOM-1'); $this->assertEquals($markdown, '[DDC-117](http://www.doctrine-project.org/jira/browse/DDC-117) [DBAL-123](http://www.doctrine-project.org/jira/browse/DBAL-123) [DCOM-1](http://www.doctrine-project.org/jira/browse/DCOM-1)'); }
} $import['comments'] = []; if (isset($issue['fields']['issuelinks']) && $issue['fields']['issuelinks']) { $comment = ""; foreach ($issue['fields']['issuelinks'] as $link) { /*if (isset($link['inwardIssue'])) { $comment .= sprintf("* %s [%s: %s](http://www.doctrine-project.org/jira/browse/%s)\n", $link['type']['inward'], $link['inwardIssue']['key'], $link['inwardIssue']['fields']['summary'], $link['inwardIssue']['key']); } else if (isset($link['outwardIssue'])) { $comment .= sprintf("* %s [%s: %s](http://www.doctrine-project.org/jira/browse/%s)\n", $link['type']['outward'], $link['outwardIssue']['key'], $link['outwardIssue']['fields']['summary'], $link['outwardIssue']['key']); }*/ } $import['comments'][] = ['body' => $comment, 'created_at' => substr($issue['fields']['created'], 0, 19) . 'Z']; } if (isset($issue['fields']['comment']) && count($issue['fields']['comment']['comments']) > 0) { foreach ($issue['fields']['comment']['comments'] as $comment) { $import['comments'][] = ['created_at' => substr($comment['created'], 0, 19) . 'Z', 'body' => sprintf("Comment created by %s:\n\n%s", mentionName($comment['author']['name']), toMarkdown($comment['body']))]; } } if (isset($issue['fields']['resolutiondate']) && $issue['fields']['resolutiondate']) { $import['comments'][] = ['created_at' => substr($issue['fields']['resolutiondate'], 0, 19) . 'Z', 'body' => sprintf('Issue was closed with resolution "%s"', $issue['fields']['resolution']['name'])]; } if (count($import['comments']) === 0) { unset($import['comments']); } file_put_contents("data/" . $project . "/" . $issue['key'] . ".json", json_encode($import, JSON_PRETTY_PRINT)); printf("Processed issue: %s (Idx: %d)\n", $issue['key'], $startAt); $startAt++; } printf("Completed batch, continuing with start at %d\n", $startAt); } function mentionName($name)