diff --git a/src/GitLab.php b/src/GitLab.php index 3cef1ac6a128a8e02550bc66ec196959ae0d6483..56f79b248a538cdadf4018803e1bd0ffde15189b 100644 --- a/src/GitLab.php +++ b/src/GitLab.php @@ -86,6 +86,17 @@ class GitLab return $issue; } + /** + * Closes an issue. + * @param mixed $projectId project ID or path + * @param int $issueId issue to close + * @param string $time time in ISO8601 format + */ + public function closeIssue($projectId, $issueId, $time) { + $this->client->api('issues')->update($projectId, $issueId, + ['state_event' => 'close', 'updated_at' => $time]); + } + /** * Creates a new note in the given project and on the given issue id (NOTE: id, not iid). When working in admin mode, tries to create the note * as the given author (SUDO) and if that fails, tries creating the note again as the admin. diff --git a/src/Migration.php b/src/Migration.php index bc6cc31ebb04d601224ca501c8caf0e9e5d8853f..82f27c9c44d35c42201f0adf3acae5c0000d4f74 100644 --- a/src/Migration.php +++ b/src/Migration.php @@ -128,9 +128,6 @@ class Migration echo "\tAlso created " . count($ticket[4]) . " note(s)\n"; }*/ - // Map old image filenames to new markdown links - $images = []; - /* * Add files attached to Trac ticket to new Gitlab issue. */ @@ -144,6 +141,11 @@ class Migration echo "\tAttached file " . $a['filename'] . " to issue " . $issue['iid'] . ".\n"; } + // Close issue if Trac ticket was closed. + if ($ticket[3]['status'] === 'closed') { + $this->gitLab->closeIssue($gitLabProject, $issue['iid'], $dateUpdated); + } + } return $mapping; }