From 188ed66da42bd3efbe4dd52a2ade4bdd1560cdaf Mon Sep 17 00:00:00 2001 From: Jeremy Zahner Date: Wed, 7 Apr 2021 15:56:51 +0200 Subject: [PATCH] Allows filtering by label for issues and merge requests. --- README.md | 6 +++++- sample_settings.ts | 1 + src/index.ts | 3 +++ src/settings.ts | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 43f21bb..13d47d7 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Existing bucket, with an appropriate security policy. One possible policy is to #### transfer.milestones -If this is set to true (default) then the migration process will transfer milestones. +If this is set to true (default) then the migration process will transfer milestones. #### transfer.labels @@ -123,6 +123,10 @@ It would of course be better to find the cause for migration fails, so that no r If this is set to true (default is false) then all merge requests will be migrated as GitHub issues (rather than pull requests). This can be used to sidestep the problem where pull requests are rejected by GitHub if the feature branch no longer exists or has been merged. +#### filterByLabel + +Filters all merge requests and issues by these labels. The applicable values can be found in the Gitlab API documentation for [issues](https://docs.gitlab.com/ee/api/issues.html#list-project-issues) and [merge requests](https://docs.gitlab.com/ee/api/merge_requests.html#list-merge-requests) respectively. Default is `null` which returns all issues/merge requests. + #### skipMatchingComments This is an array (empty per default) that may contain string values. Any note/comment in any issue, that contains one or more of those string values, will be skipped (meaining not migrated). Note that this is case insensitive, therefore the string value `foo` would also lead to skipping notes containing a (sub)string `FOO`. diff --git a/sample_settings.ts b/sample_settings.ts index 64e7c7b..f9efc27 100644 --- a/sample_settings.ts +++ b/sample_settings.ts @@ -38,6 +38,7 @@ export default { usePlaceholderIssuesForMissingIssues: true, useReplacementIssuesForCreationFails: true, useIssuesForAllMergeRequests: false, + filterByLabel: null, skipMatchingComments: [], mergeRequests: { logFile: './merge-requests.json', diff --git a/src/index.ts b/src/index.ts index f105cd8..8548f81 100644 --- a/src/index.ts +++ b/src/index.ts @@ -259,6 +259,7 @@ async function transferIssues() { // TODO return all issues via pagination let issues = await gitlabApi.Issues.all({ projectId: settings.gitlab.projectId, + labels: settings.filterByLabel, }) as any[]; // sort issues in ascending order of their issue number (by iid) @@ -375,6 +376,7 @@ async function transferMergeRequests() { // this project let mergeRequests = await gitlabApi.MergeRequests.all({ projectId: settings.gitlab.projectId, + labels: settings.filterByLabel, }) as any; // Sort merge requests in ascending order of their number (by iid) @@ -457,6 +459,7 @@ async function logMergeRequests(logFile) { // TODO return all MRs via pagination let mergeRequests = await gitlabApi.MergeRequests.all({ projectId: settings.gitlab.projectId, + labels: settings.filterByLabel, }) as any; // sort MRs in ascending order of when they were created (by id) diff --git a/src/settings.ts b/src/settings.ts index 9188f07..6de0a03 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -20,6 +20,7 @@ export default interface Settings { usePlaceholderIssuesForMissingIssues: boolean; useReplacementIssuesForCreationFails: boolean; useIssuesForAllMergeRequests: boolean; + filterByLabel: string | null; skipMatchingComments: string[]; mergeRequests: { logFile: string;