Skip to content

Indicate migration status using topics #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sample_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default {
labels: true,
issues: true,
mergeRequests: true,
migrationTopic: false,
},
debug: false,
usePlaceholderIssuesForMissingIssues: true,
Expand Down
12 changes: 12 additions & 0 deletions src/githubHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
31 changes: 31 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default interface Settings {
labels: boolean;
issues: boolean;
mergeRequests: boolean;
migrationTopic: boolean;
};
usePlaceholderIssuesForMissingIssues: boolean;
useReplacementIssuesForCreationFails: boolean;
Expand Down