Skip to content

Commit a92af49

Browse files
authored
Merge pull request #118 from mdbenito/fix/105-skip-closed-mr
Skip merge requests in given states
2 parents 5b876c4 + 4acc88b commit a92af49

4 files changed

Lines changed: 10 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ used to sidestep the problem where pull requests are rejected by GitHub if the f
155155

156156
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.
157157

158+
### skipMergeRequestStates
159+
160+
Merge requests in GitLab with any of the states listed in this array will not be transferred to GitHub (e.g. set to `['merged', 'closed']` to avoid creating issues for closed MRs whose branches have been deleted).
161+
158162
### skipMatchingComments
159163

160164
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
@@ -42,6 +42,7 @@ export default {
4242
useReplacementIssuesForCreationFails: true,
4343
useIssuesForAllMergeRequests: false,
4444
filterByLabel: null,
45+
skipMergeRequestStates: [],
4546
skipMatchingComments: [],
4647
mergeRequests: {
4748
logFile: './merge-requests.json',

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,10 @@ async function transferMergeRequests() {
437437
i => i.title.trim().includes(request.title.trim())
438438
);
439439
if (!githubRequest && !githubIssue) {
440+
if (settings.skipMergeRequestStates.includes(request.state)) {
441+
console.log(`Skipping MR ${request.iid} in "${request.state}" state: ${request.title}`)
442+
continue;
443+
}
440444
console.log(
441445
'Creating pull request: !' + request.iid + ' - ' + request.title
442446
);

src/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default interface Settings {
2222
useReplacementIssuesForCreationFails: boolean;
2323
useIssuesForAllMergeRequests: boolean;
2424
filterByLabel: string | null;
25+
skipMergeRequestStates: string[];
2526
skipMatchingComments: string[];
2627
mergeRequests: {
2728
logFile: string;

0 commit comments

Comments
 (0)