diff --git a/src/GitLab.php b/src/GitLab.php index 3b78dec68bc27bbb23307ebf07ec138f7bba3667..3cef1ac6a128a8e02550bc66ec196959ae0d6483 100644 --- a/src/GitLab.php +++ b/src/GitLab.php @@ -125,7 +125,20 @@ class GitLab $data = $this->client->api('projects')->uploadFile($projectId, $file); // Add the uploaded file as a note on the given issue. - return $this->createNote($projectId, $issueId, $data['markdown'], $authorId); + $note = $this->createNote($projectId, $issueId, $data['markdown'], $authorId); + + // Update possible mentions of this file in issue description. + $issue = $this->client->api('issues')->show($projectId, $issueId); + + $description = str_replace( + '[[br]]', + '<br>', + preg_replace('/!\[image\]\((.+),.*\)/U', $data['markdown'], $issue['description']) + ); + + $this->client->api('issues')->update($projectId, $issueId, ['description' => $description]); + + return $note; } catch (\Gitlab\Exception\RuntimeException $e) { throw $e; diff --git a/src/Migration.php b/src/Migration.php index 86f1e16225e5d16bd53cdac1bbdb1bac7f0aa376..bc6cc31ebb04d601224ca501c8caf0e9e5d8853f 100644 --- a/src/Migration.php +++ b/src/Migration.php @@ -128,9 +128,12 @@ class Migration echo "\tAlso created " . count($ticket[4]) . " note(s)\n"; }*/ - /* - * Add files attached to Trac ticket to new Gitlab issue. - */ + // Map old image filenames to new markdown links + $images = []; + + /* + * Add files attached to Trac ticket to new Gitlab issue. + */ foreach ($attachments as $a) { file_put_contents($a['filename'], base64_decode($a['content']));