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..e1c4b74 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 since the transfer is done'); + await githubHelper.replaceTopics(['gitlab-mr-migrated']); +} + +// ---------------------------------------------------------------------------- + /** * Transfer any milestones that exist in GitLab that do not exist in GitHub. */ @@ -401,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( 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;