backport 7.3.2 → 7.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/backportRun.js +7 -0
- package/dist/entrypoint.cli.js +2 -2
- package/dist/entrypoint.module.d.ts +3 -0
- package/dist/entrypoint.module.js +19 -8
- package/dist/entrypoint.module.private.test.d.ts +1 -0
- package/dist/entrypoint.module.private.test.js +592 -0
- package/dist/options/ConfigOptions.d.ts +1 -0
- package/dist/options/cliArgs.d.ts +2 -0
- package/dist/options/cliArgs.js +8 -0
- package/dist/options/config/config.d.ts +1 -0
- package/dist/options/config/readConfigFile.d.ts +1 -0
- package/dist/options/options.d.ts +2 -0
- package/dist/options/options.js +5 -5
- package/dist/options/options.test.js +9 -2
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +3 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +4 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +1 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +1 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +10 -4
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +12 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +68 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -0
- package/dist/services/prompt.test.js +1 -1
- package/dist/services/prompts.js +4 -4
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +1 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +1 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +39 -39
- package/dist/services/sourceCommit/parseSourceCommit.test.js +3 -3
- package/dist/test/e2e/cli/cli.private.test.js +3 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +1 -1
- package/dist/ui/getCommits.js +9 -3
- package/dist/ui/getCommitsWithoutBackports.test.js +2 -2
- package/dist/ui/getTargetBranches.js +1 -1
- package/dist/ui/getTargetBranches.test.js +2 -2
- package/dist/utils/filterMissingCommits.d.ts +2 -0
- package/dist/utils/filterMissingCommits.js +7 -0
- package/dist/utils/filterUnmergedCommits.d.ts +2 -0
- package/dist/utils/filterUnmergedCommits.js +7 -0
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +3 -2
|
@@ -24,12 +24,14 @@ export declare function getOptionsFromCliArgs(processArgs: readonly string[], {
|
|
|
24
24
|
githubApiBaseUrlV4?: string | undefined;
|
|
25
25
|
gitAuthorName?: string | undefined;
|
|
26
26
|
gitAuthorEmail?: string | undefined;
|
|
27
|
+
ls?: boolean | undefined;
|
|
27
28
|
mainline?: number | undefined;
|
|
28
29
|
maxNumber?: number | undefined;
|
|
29
30
|
multipleBranches?: boolean | undefined;
|
|
30
31
|
multipleCommits?: boolean | undefined;
|
|
31
32
|
noVerify?: boolean | undefined;
|
|
32
33
|
repoForkOwner?: string | undefined;
|
|
34
|
+
onlyMissing?: boolean | undefined;
|
|
33
35
|
prDescription?: string | undefined;
|
|
34
36
|
prTitle?: string | undefined;
|
|
35
37
|
prFilter?: string | undefined;
|
package/dist/options/cliArgs.js
CHANGED
|
@@ -129,6 +129,10 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
|
|
|
129
129
|
hidden: true,
|
|
130
130
|
description: `Path to log file`,
|
|
131
131
|
type: 'string',
|
|
132
|
+
})
|
|
133
|
+
.option('ls', {
|
|
134
|
+
description: 'List commits instead of backporting them',
|
|
135
|
+
type: 'boolean',
|
|
132
136
|
})
|
|
133
137
|
.option('mainline', {
|
|
134
138
|
description: 'Parent id of merge commit. Defaults to 1 when supplied without arguments',
|
|
@@ -188,6 +192,10 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
|
|
|
188
192
|
description: 'Create backports in the origin repo',
|
|
189
193
|
type: 'boolean',
|
|
190
194
|
conflicts: ['fork', 'repoForkOwner'],
|
|
195
|
+
})
|
|
196
|
+
.option('onlyMissing', {
|
|
197
|
+
description: 'Only list commits with missing or unmerged backports',
|
|
198
|
+
type: 'boolean',
|
|
191
199
|
})
|
|
192
200
|
.option('path', {
|
|
193
201
|
description: 'Only list commits touching files under the specified path',
|
|
@@ -33,6 +33,7 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
|
|
|
33
33
|
githubApiBaseUrlV3?: string | undefined;
|
|
34
34
|
githubApiBaseUrlV4?: string | undefined;
|
|
35
35
|
logFilePath?: string | undefined;
|
|
36
|
+
ls?: boolean | undefined;
|
|
36
37
|
maxNumber?: number | undefined;
|
|
37
38
|
multiple?: boolean | undefined;
|
|
38
39
|
multipleBranches?: boolean | undefined;
|
|
@@ -23,6 +23,7 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
|
|
|
23
23
|
githubApiBaseUrlV4?: string | undefined;
|
|
24
24
|
gitAuthorName?: string | undefined;
|
|
25
25
|
gitAuthorEmail?: string | undefined;
|
|
26
|
+
ls?: boolean | undefined;
|
|
26
27
|
maxNumber?: number | undefined;
|
|
27
28
|
multiple?: boolean | undefined;
|
|
28
29
|
multipleBranches?: boolean | undefined;
|
|
@@ -25,12 +25,14 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
|
|
|
25
25
|
githubApiBaseUrlV4?: string | undefined;
|
|
26
26
|
gitAuthorName?: string | undefined;
|
|
27
27
|
gitAuthorEmail?: string | undefined;
|
|
28
|
+
ls?: boolean | undefined;
|
|
28
29
|
mainline?: number | undefined;
|
|
29
30
|
maxNumber: number;
|
|
30
31
|
multipleBranches: boolean;
|
|
31
32
|
multipleCommits: boolean;
|
|
32
33
|
noVerify: boolean;
|
|
33
34
|
repoForkOwner: string;
|
|
35
|
+
onlyMissing?: boolean | undefined;
|
|
34
36
|
prDescription?: string | undefined;
|
|
35
37
|
prTitle?: string | undefined;
|
|
36
38
|
prFilter?: string | undefined;
|
package/dist/options/options.js
CHANGED
|
@@ -90,6 +90,9 @@ async function getRequiredOptions(combined) {
|
|
|
90
90
|
}
|
|
91
91
|
// require access token
|
|
92
92
|
if (!accessToken) {
|
|
93
|
+
if (combined.ci) {
|
|
94
|
+
throw new HandledError_1.HandledError(`Access token missing. It must be explicitly supplied when using "--ci" option. Example: --access-token very-secret`);
|
|
95
|
+
}
|
|
93
96
|
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
94
97
|
throw new HandledError_1.HandledError(`Please update your config file: "${globalConfigPath}".\nIt must contain a valid "accessToken".\n\nRead more: ${GLOBAL_CONFIG_DOCS_LINK}`);
|
|
95
98
|
}
|
|
@@ -99,11 +102,8 @@ async function getRequiredOptions(combined) {
|
|
|
99
102
|
githubApiBaseUrlV4: combined.githubApiBaseUrlV4,
|
|
100
103
|
accessToken,
|
|
101
104
|
});
|
|
102
|
-
if (!gitRemote.repoName) {
|
|
103
|
-
throw new HandledError_1.HandledError(`Please specify a
|
|
104
|
-
}
|
|
105
|
-
if (!gitRemote.repoOwner) {
|
|
106
|
-
throw new HandledError_1.HandledError(`Please specify a repo owner: "--repo-owner elastic".\n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
105
|
+
if (!gitRemote.repoName || !gitRemote.repoOwner) {
|
|
106
|
+
throw new HandledError_1.HandledError(`Please specify a repository: "--repo elastic/kibana".\n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
107
107
|
}
|
|
108
108
|
return {
|
|
109
109
|
accessToken,
|
|
@@ -60,7 +60,7 @@ describe('getOptions', () => {
|
|
|
60
60
|
projectConfig: defaultConfigs.projectConfig,
|
|
61
61
|
globalConfig: { accessToken: undefined },
|
|
62
62
|
});
|
|
63
|
-
await expect(() => (0, options_1.getOptions)([], {
|
|
63
|
+
await expect(() => (0, options_1.getOptions)([], {})).rejects
|
|
64
64
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
65
65
|
"Please update your config file: \\"/myHomeDir/.backport/config.json\\".
|
|
66
66
|
It must contain a valid \\"accessToken\\".
|
|
@@ -68,6 +68,13 @@ describe('getOptions', () => {
|
|
|
68
68
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
|
|
69
69
|
`);
|
|
70
70
|
});
|
|
71
|
+
it('when accessToken is missing with --ci', async () => {
|
|
72
|
+
(0, mockConfigFiles_1.mockConfigFiles)({
|
|
73
|
+
projectConfig: defaultConfigs.projectConfig,
|
|
74
|
+
globalConfig: { accessToken: undefined },
|
|
75
|
+
});
|
|
76
|
+
await expect(() => (0, options_1.getOptions)([], { ci: true })).rejects.toThrowErrorMatchingInlineSnapshot(`"Access token missing. It must be explicitly supplied when using \\"--ci\\" option. Example: --access-token very-secret"`);
|
|
77
|
+
});
|
|
71
78
|
it('when `targetBranches`, `targetBranchChoices` and `branchLabelMapping` are all empty', async () => {
|
|
72
79
|
mockProjectConfig({
|
|
73
80
|
targetBranches: undefined,
|
|
@@ -106,7 +113,7 @@ describe('getOptions', () => {
|
|
|
106
113
|
jest.spyOn(git, 'getRepoInfoFromGitRemotes').mockResolvedValue([]);
|
|
107
114
|
await expect(() => (0, options_1.getOptions)([], {})).rejects
|
|
108
115
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
109
|
-
"Please specify a
|
|
116
|
+
"Please specify a repository: \\"--repo elastic/kibana\\".
|
|
110
117
|
|
|
111
118
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
112
119
|
`);
|
|
@@ -4,7 +4,7 @@ const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken"
|
|
|
4
4
|
const fetchCommitByPullNumber_1 = require("./fetchCommitByPullNumber");
|
|
5
5
|
const fetchCommitBySha_1 = require("./fetchCommitBySha");
|
|
6
6
|
const fetchCommitsByAuthor_1 = require("./fetchCommitsByAuthor");
|
|
7
|
-
const
|
|
7
|
+
const fetchPullRequestsBySearchQuery_1 = require("./fetchPullRequestsBySearchQuery");
|
|
8
8
|
describe('allFetchers', () => {
|
|
9
9
|
let devAccessToken;
|
|
10
10
|
let commitByAuthor;
|
|
@@ -47,7 +47,7 @@ describe('allFetchers', () => {
|
|
|
47
47
|
expect(commitByAuthor).toEqual(commitBySha);
|
|
48
48
|
});
|
|
49
49
|
it('matches commitByAuthor with commitBySearchQuery', async () => {
|
|
50
|
-
const commitsBySearchQuery = await (0,
|
|
50
|
+
const commitsBySearchQuery = await (0, fetchPullRequestsBySearchQuery_1.fetchPullRequestsBySearchQuery)({
|
|
51
51
|
repoOwner: 'elastic',
|
|
52
52
|
repoName: 'kibana',
|
|
53
53
|
accessToken: devAccessToken,
|
|
@@ -5,13 +5,14 @@ export declare function fetchCommitsByAuthor(options: {
|
|
|
5
5
|
author: string | null;
|
|
6
6
|
branchLabelMapping?: ValidConfigOptions['branchLabelMapping'];
|
|
7
7
|
commitPaths?: string[];
|
|
8
|
+
dateSince: string | null;
|
|
9
|
+
dateUntil: string | null;
|
|
8
10
|
githubApiBaseUrlV4?: string;
|
|
9
11
|
maxNumber?: number;
|
|
12
|
+
onlyMissing?: boolean;
|
|
10
13
|
repoName: string;
|
|
11
14
|
repoOwner: string;
|
|
12
15
|
sourceBranch: string;
|
|
13
|
-
dateSince: string | null;
|
|
14
|
-
dateUntil: string | null;
|
|
15
16
|
}): Promise<Commit[]>;
|
|
16
17
|
export interface CommitByAuthorResponse {
|
|
17
18
|
repository: {
|
|
@@ -7,6 +7,7 @@ exports.fetchCommitsByAuthor = void 0;
|
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
9
|
const filterEmpty_1 = require("../../../../utils/filterEmpty");
|
|
10
|
+
const filterUnmergedCommits_1 = require("../../../../utils/filterUnmergedCommits");
|
|
10
11
|
const HandledError_1 = require("../../../HandledError");
|
|
11
12
|
const remoteConfig_1 = require("../../../remoteConfig");
|
|
12
13
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
@@ -100,6 +101,9 @@ async function fetchCommitsByAuthor(options) {
|
|
|
100
101
|
}
|
|
101
102
|
const commitsUnique = (0, lodash_1.uniqBy)(commits, (c) => c.sourceCommit.sha);
|
|
102
103
|
const commitsSorted = (0, lodash_1.orderBy)(commitsUnique, (c) => c.sourceCommit.committedDate, 'desc');
|
|
104
|
+
if (options.onlyMissing) {
|
|
105
|
+
return commitsSorted.filter(filterUnmergedCommits_1.filterUnmergedCommits);
|
|
106
|
+
}
|
|
103
107
|
return commitsSorted;
|
|
104
108
|
}
|
|
105
109
|
exports.fetchCommitsByAuthor = fetchCommitsByAuthor;
|
|
@@ -188,7 +188,7 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
188
188
|
it('returns missing pull requests', async () => {
|
|
189
189
|
const commitWithoutPRs = res.find((commit) => commit.sourcePullRequest?.number === 8);
|
|
190
190
|
expect(commitWithoutPRs?.expectedTargetPullRequests).toEqual([
|
|
191
|
-
{ branch: '7.x', state: '
|
|
191
|
+
{ branch: '7.x', state: 'NOT_CREATED' },
|
|
192
192
|
]);
|
|
193
193
|
});
|
|
194
194
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../../../../options/options';
|
|
2
2
|
import { Commit } from '../../../sourceCommit/parseSourceCommit';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function fetchPullRequestsBySearchQuery(options: ValidConfigOptions): Promise<Commit[]>;
|
|
@@ -3,14 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.fetchPullRequestsBySearchQuery = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
9
|
const HandledError_1 = require("../../../HandledError");
|
|
10
10
|
const remoteConfig_1 = require("../../../remoteConfig");
|
|
11
11
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
12
12
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
13
|
-
async function
|
|
13
|
+
async function fetchPullRequestsBySearchQuery(options) {
|
|
14
14
|
const { accessToken, githubApiBaseUrlV4, maxNumber = 10, prFilter, repoName, repoOwner, sourceBranch, author, } = options;
|
|
15
15
|
const query = (0, graphql_tag_1.default) `
|
|
16
16
|
query PullRequestBySearchQuery($query: String!, $maxNumber: Int!) {
|
|
@@ -58,4 +58,4 @@ async function fetchPullRequestBySearchQuery(options) {
|
|
|
58
58
|
}
|
|
59
59
|
return commits;
|
|
60
60
|
}
|
|
61
|
-
exports.
|
|
61
|
+
exports.fetchPullRequestsBySearchQuery = fetchPullRequestsBySearchQuery;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
4
|
-
const
|
|
5
|
-
describe('
|
|
4
|
+
const fetchPullRequestsBySearchQuery_1 = require("./fetchPullRequestsBySearchQuery");
|
|
5
|
+
describe('fetchPullRequestsBySearchQuery', () => {
|
|
6
6
|
let devAccessToken;
|
|
7
7
|
beforeAll(() => {
|
|
8
8
|
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
@@ -18,7 +18,13 @@ describe('fetchPullRequestBySearchQuery', () => {
|
|
|
18
18
|
sourceBranch: 'master',
|
|
19
19
|
author: 'sqren',
|
|
20
20
|
};
|
|
21
|
-
await expect((0,
|
|
21
|
+
await expect((0, fetchPullRequestsBySearchQuery_1.fetchPullRequestsBySearchQuery)(options)).rejects
|
|
22
|
+
.toThrowErrorMatchingInlineSnapshot(`
|
|
23
|
+
"No commits found for query:
|
|
24
|
+
type:pr is:merged sort:updated-desc repo:backport-org/backport-e2e author:sqren base:master label:non-existing
|
|
25
|
+
|
|
26
|
+
Use \`--all\` to see commits by all users or \`--author=<username>\` for commits from a specific user"
|
|
27
|
+
`);
|
|
22
28
|
});
|
|
23
29
|
});
|
|
24
30
|
describe('when filter matches PRs', () => {
|
|
@@ -98,7 +104,7 @@ describe('fetchPullRequestBySearchQuery', () => {
|
|
|
98
104
|
],
|
|
99
105
|
},
|
|
100
106
|
];
|
|
101
|
-
expect(await (0,
|
|
107
|
+
expect(await (0, fetchPullRequestsBySearchQuery_1.fetchPullRequestsBySearchQuery)(options)).toEqual(expectedCommits);
|
|
102
108
|
});
|
|
103
109
|
});
|
|
104
110
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Commit } from '../../../sourceCommit/parseSourceCommit';
|
|
2
|
+
export declare function fetchPullRequestsBySearchQuery(options: {
|
|
3
|
+
accessToken: string;
|
|
4
|
+
author: string | null;
|
|
5
|
+
githubApiBaseUrlV4?: string;
|
|
6
|
+
maxNumber?: number;
|
|
7
|
+
onlyMissing?: boolean;
|
|
8
|
+
prFilter: string;
|
|
9
|
+
repoName: string;
|
|
10
|
+
repoOwner: string;
|
|
11
|
+
sourceBranch: string;
|
|
12
|
+
}): Promise<Commit[]>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetchPullRequestsBySearchQuery = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
|
+
const filterUnmergedCommits_1 = require("../../../../utils/filterUnmergedCommits");
|
|
10
|
+
const HandledError_1 = require("../../../HandledError");
|
|
11
|
+
const remoteConfig_1 = require("../../../remoteConfig");
|
|
12
|
+
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
13
|
+
const apiRequestV4_1 = require("../apiRequestV4");
|
|
14
|
+
async function fetchPullRequestsBySearchQuery(options) {
|
|
15
|
+
const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxNumber = 10, prFilter, repoName, repoOwner, sourceBranch, author, } = options;
|
|
16
|
+
const query = (0, graphql_tag_1.default) `
|
|
17
|
+
query PullRequestBySearchQuery($query: String!, $maxNumber: Int!) {
|
|
18
|
+
search(query: $query, type: ISSUE, first: $maxNumber) {
|
|
19
|
+
nodes {
|
|
20
|
+
... on PullRequest {
|
|
21
|
+
mergeCommit {
|
|
22
|
+
...SourceCommitWithTargetPullRequestFragment
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
${parseSourceCommit_1.SourceCommitWithTargetPullRequestFragment}
|
|
30
|
+
`;
|
|
31
|
+
const authorFilter = options.author ? ` author:${options.author}` : '';
|
|
32
|
+
const sourceBranchFilter = prFilter.includes('base:')
|
|
33
|
+
? ''
|
|
34
|
+
: ` base:${sourceBranch}`;
|
|
35
|
+
const searchQuery = `type:pr is:merged sort:updated-desc repo:${repoOwner}/${repoName}${authorFilter}${sourceBranchFilter} ${prFilter} `;
|
|
36
|
+
const variables = {
|
|
37
|
+
query: searchQuery,
|
|
38
|
+
maxNumber,
|
|
39
|
+
};
|
|
40
|
+
let res;
|
|
41
|
+
try {
|
|
42
|
+
res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
43
|
+
githubApiBaseUrlV4,
|
|
44
|
+
accessToken,
|
|
45
|
+
query,
|
|
46
|
+
variables,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
res = (0, remoteConfig_1.swallowMissingConfigFileException)(e);
|
|
51
|
+
}
|
|
52
|
+
const commits = res.search.nodes.map((pullRequestNode) => {
|
|
53
|
+
const sourceCommit = pullRequestNode.mergeCommit;
|
|
54
|
+
return (0, parseSourceCommit_1.parseSourceCommit)({ options, sourceCommit });
|
|
55
|
+
});
|
|
56
|
+
// terminate if not commits were found
|
|
57
|
+
if ((0, lodash_1.isEmpty)(commits)) {
|
|
58
|
+
const errorText = author
|
|
59
|
+
? `No commits found for query:\n ${searchQuery}\n\nUse \`--all\` to see commits by all users or \`--author=<username>\` for commits from a specific user`
|
|
60
|
+
: `No commits found for query:\n ${searchQuery}`;
|
|
61
|
+
throw new HandledError_1.HandledError(errorText);
|
|
62
|
+
}
|
|
63
|
+
if (options.onlyMissing) {
|
|
64
|
+
return commits.filter(filterUnmergedCommits_1.filterUnmergedCommits);
|
|
65
|
+
}
|
|
66
|
+
return commits;
|
|
67
|
+
}
|
|
68
|
+
exports.fetchPullRequestsBySearchQuery = fetchPullRequestsBySearchQuery;
|
|
@@ -34,6 +34,7 @@ export declare function getOptionsFromGithub(options: {
|
|
|
34
34
|
githubApiBaseUrlV3?: string | undefined;
|
|
35
35
|
githubApiBaseUrlV4?: string | undefined;
|
|
36
36
|
logFilePath?: string | undefined;
|
|
37
|
+
ls?: boolean | undefined;
|
|
37
38
|
maxNumber?: number | undefined;
|
|
38
39
|
multiple?: boolean | undefined;
|
|
39
40
|
multipleBranches?: boolean | undefined;
|
|
@@ -28,7 +28,7 @@ describe('prompt', () => {
|
|
|
28
28
|
expectedTargetPullRequests: [
|
|
29
29
|
{ number: 120178, branch: '8.0', state: 'MERGED' },
|
|
30
30
|
{ number: 120179, branch: '7.16', state: 'MERGED' },
|
|
31
|
-
{ number: 120179, branch: '7.15', state: '
|
|
31
|
+
{ number: 120179, branch: '7.15', state: 'NOT_CREATED' },
|
|
32
32
|
],
|
|
33
33
|
},
|
|
34
34
|
];
|
package/dist/services/prompts.js
CHANGED
|
@@ -19,7 +19,7 @@ function getPrStateIcon(state) {
|
|
|
19
19
|
if (state === 'MERGED') {
|
|
20
20
|
return '🟢';
|
|
21
21
|
}
|
|
22
|
-
if (state === '
|
|
22
|
+
if (state === 'NOT_CREATED') {
|
|
23
23
|
return '🔴';
|
|
24
24
|
}
|
|
25
25
|
if (state === 'OPEN') {
|
|
@@ -32,8 +32,8 @@ function getPrStateText(state) {
|
|
|
32
32
|
if (state === 'MERGED') {
|
|
33
33
|
return chalk_1.default.gray('Merged');
|
|
34
34
|
}
|
|
35
|
-
if (state === '
|
|
36
|
-
return chalk_1.default.gray('Backport
|
|
35
|
+
if (state === 'NOT_CREATED') {
|
|
36
|
+
return chalk_1.default.gray('Backport not created');
|
|
37
37
|
}
|
|
38
38
|
if (state === 'OPEN') {
|
|
39
39
|
return chalk_1.default.gray('Open, not merged');
|
|
@@ -59,7 +59,7 @@ function getSimplePullStatus(c) {
|
|
|
59
59
|
if (state === 'MERGED') {
|
|
60
60
|
return chalk_1.default.green(branch);
|
|
61
61
|
}
|
|
62
|
-
if (state === '
|
|
62
|
+
if (state === 'NOT_CREATED') {
|
|
63
63
|
return chalk_1.default.red(branch);
|
|
64
64
|
}
|
|
65
65
|
if (state === 'OPEN') {
|
|
@@ -76,7 +76,7 @@ function getMissingTargetPullRequests(sourcePullRequest, existingTargetPullReque
|
|
|
76
76
|
return expected
|
|
77
77
|
.filter((targetBranch) => !expectedTargetBranches.includes(targetBranch))
|
|
78
78
|
.map((branch) => {
|
|
79
|
-
return { branch, state: '
|
|
79
|
+
return { branch, state: 'NOT_CREATED' };
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
// narrow TimelineEdge to TimelinePullRequestEdge
|
|
@@ -211,8 +211,8 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
211
211
|
latestBranchLabelMapping: branchLabelMapping,
|
|
212
212
|
});
|
|
213
213
|
expect(expectedTargetPullRequests).toEqual([
|
|
214
|
-
{ branch: '7.2', state: '
|
|
215
|
-
{ branch: '7.1', state: '
|
|
214
|
+
{ branch: '7.2', state: 'NOT_CREATED' },
|
|
215
|
+
{ branch: '7.1', state: 'NOT_CREATED' },
|
|
216
216
|
]);
|
|
217
217
|
});
|
|
218
218
|
it('should not show merged PRs as missing', () => {
|
|
@@ -251,7 +251,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
251
251
|
sha: 'target-merge-commit-sha',
|
|
252
252
|
},
|
|
253
253
|
},
|
|
254
|
-
{ branch: '7.1', state: '
|
|
254
|
+
{ branch: '7.1', state: 'NOT_CREATED' },
|
|
255
255
|
]);
|
|
256
256
|
});
|
|
257
257
|
it(`should support Kibana's label format`, () => {
|
|
@@ -296,28 +296,28 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
296
296
|
latestBranchLabelMapping: branchLabelMapping,
|
|
297
297
|
});
|
|
298
298
|
expect(expectedTargetPullRequests).toEqual([
|
|
299
|
-
{ branch: '5.4', state: '
|
|
300
|
-
{ branch: '5.5', state: '
|
|
301
|
-
{ branch: '5.6', state: '
|
|
302
|
-
{ branch: '6.0', state: '
|
|
303
|
-
{ branch: '6.1', state: '
|
|
304
|
-
{ branch: '6.2', state: '
|
|
305
|
-
{ branch: '6.3', state: '
|
|
306
|
-
{ branch: '6.4', state: '
|
|
307
|
-
{ branch: '6.5', state: '
|
|
308
|
-
{ branch: '6.6', state: '
|
|
309
|
-
{ branch: '6.7', state: '
|
|
310
|
-
{ branch: '6.8', state: '
|
|
311
|
-
{ branch: '7.0', state: '
|
|
312
|
-
{ branch: '7.1', state: '
|
|
313
|
-
{ branch: '7.2', state: '
|
|
314
|
-
{ branch: '7.3', state: '
|
|
315
|
-
{ branch: '7.4', state: '
|
|
316
|
-
{ branch: '7.5', state: '
|
|
317
|
-
{ branch: '7.6', state: '
|
|
318
|
-
{ branch: '7.7', state: '
|
|
319
|
-
{ branch: '7.x', state: '
|
|
320
|
-
{ branch: 'master', state: '
|
|
299
|
+
{ branch: '5.4', state: 'NOT_CREATED' },
|
|
300
|
+
{ branch: '5.5', state: 'NOT_CREATED' },
|
|
301
|
+
{ branch: '5.6', state: 'NOT_CREATED' },
|
|
302
|
+
{ branch: '6.0', state: 'NOT_CREATED' },
|
|
303
|
+
{ branch: '6.1', state: 'NOT_CREATED' },
|
|
304
|
+
{ branch: '6.2', state: 'NOT_CREATED' },
|
|
305
|
+
{ branch: '6.3', state: 'NOT_CREATED' },
|
|
306
|
+
{ branch: '6.4', state: 'NOT_CREATED' },
|
|
307
|
+
{ branch: '6.5', state: 'NOT_CREATED' },
|
|
308
|
+
{ branch: '6.6', state: 'NOT_CREATED' },
|
|
309
|
+
{ branch: '6.7', state: 'NOT_CREATED' },
|
|
310
|
+
{ branch: '6.8', state: 'NOT_CREATED' },
|
|
311
|
+
{ branch: '7.0', state: 'NOT_CREATED' },
|
|
312
|
+
{ branch: '7.1', state: 'NOT_CREATED' },
|
|
313
|
+
{ branch: '7.2', state: 'NOT_CREATED' },
|
|
314
|
+
{ branch: '7.3', state: 'NOT_CREATED' },
|
|
315
|
+
{ branch: '7.4', state: 'NOT_CREATED' },
|
|
316
|
+
{ branch: '7.5', state: 'NOT_CREATED' },
|
|
317
|
+
{ branch: '7.6', state: 'NOT_CREATED' },
|
|
318
|
+
{ branch: '7.7', state: 'NOT_CREATED' },
|
|
319
|
+
{ branch: '7.x', state: 'NOT_CREATED' },
|
|
320
|
+
{ branch: 'master', state: 'NOT_CREATED' },
|
|
321
321
|
]);
|
|
322
322
|
});
|
|
323
323
|
it(`should support "backport-to" format`, () => {
|
|
@@ -336,8 +336,8 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
336
336
|
latestBranchLabelMapping: branchLabelMapping,
|
|
337
337
|
});
|
|
338
338
|
expect(expectedTargetPullRequests).toEqual([
|
|
339
|
-
{ branch: 'dev', state: '
|
|
340
|
-
{ branch: 'v3.1.0', state: '
|
|
339
|
+
{ branch: 'dev', state: 'NOT_CREATED' },
|
|
340
|
+
{ branch: 'v3.1.0', state: 'NOT_CREATED' },
|
|
341
341
|
]);
|
|
342
342
|
});
|
|
343
343
|
it('should only get first match', () => {
|
|
@@ -357,7 +357,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
357
357
|
latestBranchLabelMapping: branchLabelMapping,
|
|
358
358
|
});
|
|
359
359
|
expect(expectedTargetPullRequests).toEqual([
|
|
360
|
-
{ branch: 'branch-b', state: '
|
|
360
|
+
{ branch: 'branch-b', state: 'NOT_CREATED' },
|
|
361
361
|
]);
|
|
362
362
|
});
|
|
363
363
|
it('shows open PRs', () => {
|
|
@@ -390,12 +390,12 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
390
390
|
state: 'OPEN',
|
|
391
391
|
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
392
392
|
},
|
|
393
|
-
{ branch: 'branch-1', state: '
|
|
394
|
-
{ branch: 'branch-2', state: '
|
|
395
|
-
{ branch: 'branch-4', state: '
|
|
393
|
+
{ branch: 'branch-1', state: 'NOT_CREATED' },
|
|
394
|
+
{ branch: 'branch-2', state: 'NOT_CREATED' },
|
|
395
|
+
{ branch: 'branch-4', state: 'NOT_CREATED' },
|
|
396
396
|
]);
|
|
397
397
|
});
|
|
398
|
-
it('ignores closed PRs (treats them as
|
|
398
|
+
it('ignores closed PRs (treats them as NOT_CREATED)', () => {
|
|
399
399
|
const branchLabelMapping = {
|
|
400
400
|
'label-(\\d+)': 'branch-$1',
|
|
401
401
|
};
|
|
@@ -419,10 +419,10 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
419
419
|
latestBranchLabelMapping: branchLabelMapping,
|
|
420
420
|
});
|
|
421
421
|
expect(expectedTargetPullRequests).toEqual([
|
|
422
|
-
{ branch: 'branch-1', state: '
|
|
423
|
-
{ branch: 'branch-2', state: '
|
|
424
|
-
{ branch: 'branch-3', state: '
|
|
425
|
-
{ branch: 'branch-4', state: '
|
|
422
|
+
{ branch: 'branch-1', state: 'NOT_CREATED' },
|
|
423
|
+
{ branch: 'branch-2', state: 'NOT_CREATED' },
|
|
424
|
+
{ branch: 'branch-3', state: 'NOT_CREATED' },
|
|
425
|
+
{ branch: 'branch-4', state: 'NOT_CREATED' },
|
|
426
426
|
]);
|
|
427
427
|
});
|
|
428
428
|
it('shows merged PRs', () => {
|
|
@@ -459,9 +459,9 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
459
459
|
sha: 'target-merge-commit-sha',
|
|
460
460
|
},
|
|
461
461
|
},
|
|
462
|
-
{ branch: 'branch-1', state: '
|
|
463
|
-
{ branch: 'branch-2', state: '
|
|
464
|
-
{ branch: 'branch-4', state: '
|
|
462
|
+
{ branch: 'branch-1', state: 'NOT_CREATED' },
|
|
463
|
+
{ branch: 'branch-2', state: 'NOT_CREATED' },
|
|
464
|
+
{ branch: 'branch-4', state: 'NOT_CREATED' },
|
|
465
465
|
]);
|
|
466
466
|
});
|
|
467
467
|
});
|
|
@@ -97,7 +97,7 @@ describe('parseSourceCommit', () => {
|
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
branch: '6.1',
|
|
100
|
-
state: '
|
|
100
|
+
state: 'NOT_CREATED',
|
|
101
101
|
},
|
|
102
102
|
]);
|
|
103
103
|
});
|
|
@@ -146,7 +146,7 @@ describe('parseSourceCommit', () => {
|
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
148
|
branch: '6.1',
|
|
149
|
-
state: '
|
|
149
|
+
state: 'NOT_CREATED',
|
|
150
150
|
},
|
|
151
151
|
]);
|
|
152
152
|
});
|
|
@@ -217,7 +217,7 @@ describe('parseSourceCommit', () => {
|
|
|
217
217
|
},
|
|
218
218
|
{
|
|
219
219
|
branch: '6.1',
|
|
220
|
-
state: '
|
|
220
|
+
state: 'NOT_CREATED',
|
|
221
221
|
},
|
|
222
222
|
],
|
|
223
223
|
};
|
|
@@ -74,6 +74,7 @@ describe('backport cli', () => {
|
|
|
74
74
|
[boolean]
|
|
75
75
|
--gitAuthorName Set commit author name [string]
|
|
76
76
|
--gitAuthorEmail Set commit author email [string]
|
|
77
|
+
--ls List commits instead of backporting them [boolean]
|
|
77
78
|
--mainline Parent id of merge commit. Defaults to 1 when supplied
|
|
78
79
|
without arguments [number]
|
|
79
80
|
-n, --maxNumber, --number Number of commits to choose from [number]
|
|
@@ -85,6 +86,8 @@ describe('backport cli', () => {
|
|
|
85
86
|
--noStatusComment Don't publish status comment to Github [boolean]
|
|
86
87
|
--noVerify Bypass the pre-commit and commit-msg hooks [boolean]
|
|
87
88
|
--noFork Create backports in the origin repo [boolean]
|
|
89
|
+
--onlyMissing Only list commits with missing or unmerged backports
|
|
90
|
+
[boolean]
|
|
88
91
|
-p, --path Only list commits touching files under the specified path
|
|
89
92
|
[array]
|
|
90
93
|
--prDescription, --description Description to be added to pull request [string]
|
|
@@ -30,7 +30,7 @@ describe('Handle unbackported pull requests', () => {
|
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
sourceBranch: 'main',
|
|
33
|
-
expectedTargetPullRequests: [{ branch: '7.x', state: '
|
|
33
|
+
expectedTargetPullRequests: [{ branch: '7.x', state: 'NOT_CREATED' }],
|
|
34
34
|
};
|
|
35
35
|
expect(commits[0]).toEqual(expectedCommit);
|
|
36
36
|
});
|