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

replace image links in ticket description

parent 0e9bf431
No related branches found
No related tags found
No related merge requests found
...@@ -125,7 +125,20 @@ class GitLab ...@@ -125,7 +125,20 @@ class GitLab
$data = $this->client->api('projects')->uploadFile($projectId, $file); $data = $this->client->api('projects')->uploadFile($projectId, $file);
// Add the uploaded file as a note on the given issue. // 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) { } catch (\Gitlab\Exception\RuntimeException $e) {
throw $e; throw $e;
......
...@@ -128,9 +128,12 @@ class Migration ...@@ -128,9 +128,12 @@ class Migration
echo "\tAlso created " . count($ticket[4]) . " note(s)\n"; echo "\tAlso created " . count($ticket[4]) . " note(s)\n";
}*/ }*/
/* // Map old image filenames to new markdown links
* Add files attached to Trac ticket to new Gitlab issue. $images = [];
*/
/*
* Add files attached to Trac ticket to new Gitlab issue.
*/
foreach ($attachments as $a) { foreach ($attachments as $a) {
file_put_contents($a['filename'], base64_decode($a['content'])); file_put_contents($a['filename'], base64_decode($a['content']));
......
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