Skip to content

Commit 188ed66

Browse files
committed
Allows filtering by label for issues and merge requests.
1 parent 3916ec9 commit 188ed66

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Existing bucket, with an appropriate security policy. One possible policy is to
9090

9191
#### transfer.milestones
9292

93-
If this is set to true (default) then the migration process will transfer milestones.
93+
If this is set to true (default) then the migration process will transfer milestones.
9494

9595
#### transfer.labels
9696

@@ -123,6 +123,10 @@ It would of course be better to find the cause for migration fails, so that no r
123123
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
124124
used to sidestep the problem where pull requests are rejected by GitHub if the feature branch no longer exists or has been merged.
125125

126+
#### filterByLabel
127+
128+
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.
129+
126130
#### skipMatchingComments
127131

128132
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`.

sample_settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default {
3838
usePlaceholderIssuesForMissingIssues: true,
3939
useReplacementIssuesForCreationFails: true,
4040
useIssuesForAllMergeRequests: false,
41+
filterByLabel: null,
4142
skipMatchingComments: [],
4243
mergeRequests: {
4344
logFile: './merge-requests.json',

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ async function transferIssues() {
259259
// TODO return all issues via pagination
260260
let issues = await gitlabApi.Issues.all({
261261
projectId: settings.gitlab.projectId,
262+
labels: settings.filterByLabel,
262263
}) as any[];
263264

264265
// sort issues in ascending order of their issue number (by iid)
@@ -375,6 +376,7 @@ async function transferMergeRequests() {
375376
// this project
376377
let mergeRequests = await gitlabApi.MergeRequests.all({
377378
projectId: settings.gitlab.projectId,
379+
labels: settings.filterByLabel,
378380
}) as any;
379381

380382
// Sort merge requests in ascending order of their number (by iid)
@@ -457,6 +459,7 @@ async function logMergeRequests(logFile) {
457459
// TODO return all MRs via pagination
458460
let mergeRequests = await gitlabApi.MergeRequests.all({
459461
projectId: settings.gitlab.projectId,
462+
labels: settings.filterByLabel,
460463
}) as any;
461464

462465
// sort MRs in ascending order of when they were created (by id)

src/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default interface Settings {
2020
usePlaceholderIssuesForMissingIssues: boolean;
2121
useReplacementIssuesForCreationFails: boolean;
2222
useIssuesForAllMergeRequests: boolean;
23+
filterByLabel: string | null;
2324
skipMatchingComments: string[];
2425
mergeRequests: {
2526
logFile: string;

0 commit comments

Comments
 (0)