Skip to content
Snippets Groups Projects
Commit aa72fa19 authored by Thomas Hackl's avatar Thomas Hackl
Browse files

migrate ticket attachments to issues

parent e0e590d9
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,7 @@ class GitLab
$page = 1;
// Stop when we either have all users or we have exhausted the sane number of attempts
while (!$gotAll && $page < USER_FETCH_MAX_PAGES) {
$response = $this->client->api('users')->all(null, $page++, USER_FETCH_PAGE_SIZE);
$response = $this->client->api('users')->all([], $page++, USER_FETCH_PAGE_SIZE);
foreach($response as $user) {
$users[$user['username']] = $user;
// We assume that 'Administrator' user is in there
......
......@@ -123,7 +123,7 @@ class Migration
$commentAuthor = $this->getGitLabUser($comment['author']);
$commentAuthorId = is_array($commentAuthor) ? $commentAuthor['id'] : null;
$commentText = $this->translateTracToMarkdown($comment['text']);
$note = $this->gitLab->createNote($gitLabProject, $issue['id'], $commentText, $commentAuthorId);
$note = $this->gitLab->createNote($gitLabProject, $issue['iid'], $commentText, $commentAuthorId);
}
echo "\tAlso created " . count($ticket[4]) . " note(s)\n";
}*/
......@@ -133,12 +133,12 @@ class Migration
*/
foreach ($attachments as $a) {
$file = file_put_contents($a['filename'], $a['content']['__jsonclass__'][1]);
file_put_contents($a['filename'], base64_decode($a['content']));
$this->gitLab->createIssueAttachment($gitLabProject, $issue['id'], $a['filename'], $a['author']);
$this->gitLab->createIssueAttachment($gitLabProject, $issue['iid'], $a['filename'], $a['author']);
unlink($a['filename']);
echo "\tAttached file " . $a['filename'] . " to issue " . $issue['id'] . ".\n";
echo "\tAttached file " . $a['filename'] . " to issue " . $issue['iid'] . ".\n";
}
}
......
......@@ -68,9 +68,11 @@ class Trac
$attachments = $this->client->execute('ticket.listAttachments', [$id]);
foreach ($attachments as $attachment) {
$data = $this->client->execute('ticket.getAttachment', [$id, $attachment[0]]);
$result[] = [
'filename' => $attachment[0],
'content' => $this->client->execute('ticket.getAttachment', [$id, $attachment[0]]),
'content' => $data['__jsonclass__'][1],
'author' => $attachment[4]
];
......
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