From 510ef3d008ac5c979d66d8e0e00a685b5659f42d Mon Sep 17 00:00:00 2001 From: Antti Kaihola <13725+akaihola@users.noreply.github.com> Date: Tue, 16 Nov 2021 14:25:33 +0200 Subject: [PATCH 1/2] Allow setting migrating/migrated topic This setting enables setting a `github-mr-migrating` GitHub repository topic for the duration of the migration, and a `github-mr-migrated` topic to signal completion. --- sample_settings.ts | 1 + src/githubHelper.ts | 12 ++++++++++++ src/index.ts | 30 ++++++++++++++++++++++++++++++ src/settings.ts | 1 + 4 files changed, 44 insertions(+) diff --git a/sample_settings.ts b/sample_settings.ts index f9efc27..9e9e0c9 100644 --- a/sample_settings.ts +++ b/sample_settings.ts @@ -33,6 +33,7 @@ export default { labels: true, issues: true, mergeRequests: true, + migrationTopic: false, }, debug: false, usePlaceholderIssuesForMissingIssues: true, diff --git a/src/githubHelper.ts b/src/githubHelper.ts index 2ef1f36..d232eff 100644 --- a/src/githubHelper.ts +++ b/src/githubHelper.ts @@ -205,6 +205,18 @@ export default class GithubHelper { ****************************************************************************** */ + /** + * Replace the topics of the repository on GitHub. + */ + async replaceTopics(topics) { + let props : RestEndpointMethodTypes["repos"]["replaceAllTopics"]["parameters"] = { + owner: this.githubOwner, + repo: this.githubRepo, + names: topics + } + return this.githubApi.repos.replaceAllTopics(props); + } + /** * TODO description */ diff --git a/src/index.ts b/src/index.ts index 8548f81..d131034 100644 --- a/src/index.ts +++ b/src/index.ts @@ -127,6 +127,11 @@ async function migrate() { await githubHelper.registerRepoId(); + // set the gitlab-mr-migrating topic for the repository during the migration + if (settings.transfer.migrationTopic) { + await setMigratingTopic(); + } + // transfer GitLab milestones to GitHub if (settings.transfer.milestones) { await transferMilestones(); @@ -154,11 +159,36 @@ async function migrate() { console.error(err); } + // set the gitlab-mr-migrated topic for the repository when migration is done + if (settings.transfer.migrationTopic) { + await setMigratedTopic(); + } + console.log('\n\nTransfer complete!\n\n'); } // ---------------------------------------------------------------------------- +/** + * Set the gitlab-mr-migrating topic. + */ +async function setMigratingTopic() { + inform('Setting the gitlab-mr-migrating topic during the transfer'); + await githubHelper.replaceTopics(['gitlab-mr-migrating']); +} + +// ---------------------------------------------------------------------------- + +/** + * Set the gitlab-mr-migrated topic. + */ +async function setMigratedTopic() { + inform('Setting the gitlab-mr-migrated topic during the transfer'); + await githubHelper.replaceTopics(['gitlab-mr-migrated']); +} + +// ---------------------------------------------------------------------------- + /** * Transfer any milestones that exist in GitLab that do not exist in GitHub. */ diff --git a/src/settings.ts b/src/settings.ts index 6de0a03..598207d 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -16,6 +16,7 @@ export default interface Settings { labels: boolean; issues: boolean; mergeRequests: boolean; + migrationTopic: boolean; }; usePlaceholderIssuesForMissingIssues: boolean; useReplacementIssuesForCreationFails: boolean; From 2977148ac9ec5ccbd8305b3acc1e4c705201b941 Mon Sep 17 00:00:00 2001 From: Antti Kaihola <13725+akaihola@users.noreply.github.com> Date: Wed, 24 Nov 2021 09:24:49 +0200 Subject: [PATCH 2/2] Fix wording for migrated topic log message --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index d131034..e1c4b74 100644 --- a/src/index.ts +++ b/src/index.ts @@ -183,7 +183,7 @@ async function setMigratingTopic() { * Set the gitlab-mr-migrated topic. */ async function setMigratedTopic() { - inform('Setting the gitlab-mr-migrated topic during the transfer'); + inform('Setting the gitlab-mr-migrated topic since the transfer is done'); await githubHelper.replaceTopics(['gitlab-mr-migrated']); } @@ -431,6 +431,7 @@ async function transferMergeRequests() { // if a GitLab merge request does not exist in GitHub repo, create it -- along // with comments for (let request of mergeRequests) { + // if (request.iid < 333) continue; // Try to find a GitHub pull request that already exists for this GitLab // merge request let githubRequest = githubPullRequests.find(