backport 8.0.0 → 8.1.0
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 +4 -4
- package/dist/backportRun.d.ts +5 -4
- package/dist/backportRun.js +41 -42
- package/dist/entrypoint.cli.js +3 -7
- package/dist/entrypoint.module.d.ts +7 -5
- package/dist/entrypoint.module.js +11 -9
- package/dist/entrypoint.module.private.test.js +4 -4
- package/dist/errors/BackportError.d.ts +19 -0
- package/dist/errors/BackportError.js +29 -0
- package/dist/lib/BackportError.d.ts +19 -0
- package/dist/lib/BackportError.js +29 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.d.ts +13 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +238 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.test.js +321 -0
- package/dist/lib/child-process-promisified.d.ts +25 -0
- package/dist/lib/child-process-promisified.js +58 -0
- package/dist/lib/env.d.ts +7 -0
- package/dist/lib/env.js +33 -0
- package/dist/lib/env.test.d.ts +1 -0
- package/dist/lib/env.test.js +26 -0
- package/dist/lib/getCommits.d.ts +2 -0
- package/dist/lib/getCommits.js +75 -0
- package/dist/lib/getCommitsWithoutBackports.d.ts +11 -0
- package/dist/lib/getCommitsWithoutBackports.js +68 -0
- package/dist/lib/getCommitsWithoutBackports.test.d.ts +1 -0
- package/dist/lib/getCommitsWithoutBackports.test.js +335 -0
- package/dist/lib/getGitConfigAuthor.d.ts +6 -0
- package/dist/lib/getGitConfigAuthor.js +15 -0
- package/dist/lib/getTargetBranches.d.ts +5 -0
- package/dist/lib/getTargetBranches.js +67 -0
- package/dist/lib/getTargetBranches.test.d.ts +1 -0
- package/dist/lib/getTargetBranches.test.js +206 -0
- package/dist/lib/git.d.ts +77 -0
- package/dist/lib/git.js +439 -0
- package/dist/lib/git.private.test.d.ts +1 -0
- package/dist/lib/git.private.test.js +618 -0
- package/dist/lib/git.test.d.ts +1 -0
- package/dist/lib/git.test.js +580 -0
- package/dist/lib/github/commitFormatters.d.ts +3 -0
- package/dist/lib/github/commitFormatters.js +17 -0
- package/dist/lib/github/commitFormatters.test.d.ts +1 -0
- package/dist/lib/github/commitFormatters.test.js +11 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.js +32 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.test.d.ts +1 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.test.js +27 -0
- package/dist/lib/github/v3/addLabelsToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addLabelsToPullRequest.js +30 -0
- package/dist/lib/github/v3/addReviewersToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addReviewersToPullRequest.js +32 -0
- package/dist/lib/github/v3/createPullRequest.d.ts +29 -0
- package/dist/lib/github/v3/createPullRequest.js +91 -0
- package/dist/lib/github/v3/createPullRequest.test.d.ts +1 -0
- package/dist/lib/github/v3/createPullRequest.test.js +377 -0
- package/dist/lib/github/v3/createStatusComment.d.ts +11 -0
- package/dist/lib/github/v3/createStatusComment.js +136 -0
- package/dist/lib/github/v3/createStatusComment.test.d.ts +1 -0
- package/dist/lib/github/v3/createStatusComment.test.js +461 -0
- package/dist/lib/github/v3/getGithubV3ErrorMessage.d.ts +14 -0
- package/dist/lib/github/v3/getGithubV3ErrorMessage.js +16 -0
- package/dist/lib/github/v4/FetchPullRequestId.d.ts +2 -0
- package/dist/lib/github/v4/FetchPullRequestId.js +36 -0
- package/dist/lib/github/v4/apiRequestV4.d.ts +31 -0
- package/dist/lib/github/v4/apiRequestV4.js +71 -0
- package/dist/lib/github/v4/apiRequestV4.test.d.ts +1 -0
- package/dist/lib/github/v4/apiRequestV4.test.js +109 -0
- package/dist/lib/github/v4/disablePullRequestAutoMerge.d.ts +2 -0
- package/dist/lib/github/v4/disablePullRequestAutoMerge.js +32 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.d.ts +2 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.js +50 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
- package/dist/lib/github/v4/fetchAuthorId.d.ts +10 -0
- package/dist/lib/github/v4/fetchAuthorId.js +28 -0
- package/dist/lib/github/v4/fetchAuthorId.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchAuthorId.private.test.js +25 -0
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +93 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +11 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.js +58 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +136 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.d.ts +11 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.js +48 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js +118 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +29 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.js +110 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +196 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +157 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +107 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +12 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +69 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.d.ts +9 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.js +64 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.private.test.js +44 -0
- package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.d.ts +2 -0
- package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.js +39 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.d.ts +8 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.js +49 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.js +49 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +72 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +78 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +116 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.d.ts +16 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.js +29 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.js +61 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +1 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +72 -0
- package/dist/lib/github/v4/mocks/commitsByAuthorMock.d.ts +2 -0
- package/dist/lib/github/v4/mocks/commitsByAuthorMock.js +176 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.d.ts +7 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.js +45 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.test.d.ts +1 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.test.js +87 -0
- package/dist/lib/logger.d.ts +9 -0
- package/dist/lib/logger.js +74 -0
- package/dist/lib/ora.d.ts +2 -0
- package/dist/lib/ora.js +21 -0
- package/dist/lib/prompt.test.d.ts +1 -0
- package/dist/lib/prompt.test.js +139 -0
- package/dist/lib/prompts.d.ts +17 -0
- package/dist/lib/prompts.js +132 -0
- package/dist/lib/remoteConfig.d.ts +20 -0
- package/dist/lib/remoteConfig.js +52 -0
- package/dist/lib/sequentially.d.ts +1 -0
- package/dist/lib/sequentially.js +10 -0
- package/dist/lib/setupRepo.d.ts +2 -0
- package/dist/lib/setupRepo.js +56 -0
- package/dist/lib/setupRepo.test.d.ts +1 -0
- package/dist/lib/setupRepo.test.js +278 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.d.ts +16 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.js +102 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.js +467 -0
- package/dist/lib/sourceCommit/getMockSourceCommit.d.ts +26 -0
- package/dist/lib/sourceCommit/getMockSourceCommit.js +103 -0
- package/dist/lib/sourceCommit/parseSourceCommit.d.ts +108 -0
- package/dist/lib/sourceCommit/parseSourceCommit.js +123 -0
- package/dist/lib/sourceCommit/parseSourceCommit.test.d.ts +1 -0
- package/dist/lib/sourceCommit/parseSourceCommit.test.js +226 -0
- package/dist/options/ConfigOptions.d.ts +4 -2
- package/dist/options/cliArgs.d.ts +15 -12
- package/dist/options/cliArgs.js +34 -19
- package/dist/options/cliArgs.test.js +125 -1
- package/dist/options/config/config.d.ts +5 -4
- package/dist/options/config/config.js +3 -5
- package/dist/options/config/config.test.js +0 -1
- package/dist/options/config/globalConfig.d.ts +3 -1
- package/dist/options/config/globalConfig.js +5 -5
- package/dist/options/config/readConfigFile.d.ts +9 -7
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +43 -7
- package/dist/options/options.js +20 -24
- package/dist/options/options.test.js +112 -54
- package/dist/runSequentially.d.ts +10 -7
- package/dist/runSequentially.js +5 -5
- package/dist/scripts/postinstall.js +3 -3
- package/dist/scripts/postinstall.test.js +1 -1
- package/dist/services/BackportError.d.ts +19 -0
- package/dist/services/BackportError.js +29 -0
- package/dist/services/HandledBackportError.d.ts +19 -0
- package/dist/services/HandledBackportError.js +29 -0
- package/dist/services/HandledError.d.ts +1 -1
- package/dist/services/HandledError.js +5 -5
- package/dist/services/git.js +7 -7
- package/dist/services/github/v3/createPullRequest.js +2 -2
- package/dist/services/github/v3/createStatusComment.js +2 -2
- package/dist/services/github/v3/createStatusComment.test.js +5 -4
- package/dist/services/github/v4/apiRequestV4.js +2 -2
- package/dist/services/github/v4/apiRequestV4.test.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +2 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +2 -2
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +5 -5
- package/dist/state.d.ts +0 -0
- package/dist/state.js +1 -0
- package/dist/test/e2e/cli/commit-author.private.test.js +4 -4
- package/dist/test/e2e/cli/different-merge-strategies.private.test.js +26 -24
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +189 -140
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +12 -14
- package/dist/test/e2e/cli/runBackportViaCli.d.ts +5 -2
- package/dist/test/e2e/cli/runBackportViaCli.js +42 -29
- package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +22 -14
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +2 -2
- package/dist/test/handleUnbackportedPullRequests.private.test.js +3 -2
- package/dist/test/setupFiles/automatic-mocks.js +1 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +3 -3
- package/dist/ui/getCommits.js +2 -2
- package/dist/ui/getTargetBranches.js +3 -3
- package/dist/ui/setupRepo.js +2 -2
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +12 -12
- package/yarn.lock +112 -65
|
@@ -29,8 +29,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
30
30
|
const os_1 = __importDefault(require("os"));
|
|
31
31
|
const nock_1 = __importDefault(require("nock"));
|
|
32
|
-
const git = __importStar(require("../
|
|
33
|
-
const logger = __importStar(require("../
|
|
32
|
+
const git = __importStar(require("../lib/git"));
|
|
33
|
+
const logger = __importStar(require("../lib/logger"));
|
|
34
34
|
const mockConfigFiles_1 = require("../test/mockConfigFiles");
|
|
35
35
|
const nockHelpers_1 = require("../test/nockHelpers");
|
|
36
36
|
const options_1 = require("./options");
|
|
@@ -64,29 +64,23 @@ describe('getOptions', () => {
|
|
|
64
64
|
projectConfig: defaultConfigs.projectConfig,
|
|
65
65
|
globalConfig: { accessToken: undefined },
|
|
66
66
|
});
|
|
67
|
-
await expect(() => (0, options_1.getOptions)(
|
|
68
|
-
|
|
67
|
+
await expect(() => (0, options_1.getOptions)({
|
|
68
|
+
optionsFromCliArgs: {},
|
|
69
|
+
optionsFromModule: {},
|
|
70
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
69
71
|
"Please update your config file: \\"/myHomeDir/.backport/config.json\\".
|
|
70
72
|
It must contain a valid \\"accessToken\\".
|
|
71
73
|
|
|
72
74
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
|
|
73
75
|
`);
|
|
74
76
|
});
|
|
75
|
-
it('when accessToken is missing with --ci', async () => {
|
|
76
|
-
(0, mockConfigFiles_1.mockConfigFiles)({
|
|
77
|
-
projectConfig: defaultConfigs.projectConfig,
|
|
78
|
-
globalConfig: { accessToken: undefined },
|
|
79
|
-
});
|
|
80
|
-
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"`);
|
|
81
|
-
});
|
|
82
77
|
it('when `targetBranches`, `targetBranchChoices` and `branchLabelMapping` are all empty', async () => {
|
|
83
78
|
mockProjectConfig({
|
|
84
79
|
targetBranches: undefined,
|
|
85
80
|
targetBranchChoices: undefined,
|
|
86
81
|
branchLabelMapping: undefined,
|
|
87
82
|
});
|
|
88
|
-
await expect(() => (0, options_1.getOptions)(
|
|
89
|
-
.toThrowErrorMatchingInlineSnapshot(`
|
|
83
|
+
await expect(() => (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
90
84
|
"Please specify a target branch: \\"--branch 6.1\\".
|
|
91
85
|
|
|
92
86
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
@@ -94,14 +88,22 @@ describe('getOptions', () => {
|
|
|
94
88
|
});
|
|
95
89
|
describe('whe option is an empty string', () => {
|
|
96
90
|
it('throws for "username"', async () => {
|
|
97
|
-
await expect(() => (0, options_1.getOptions)(
|
|
91
|
+
await expect(() => (0, options_1.getOptions)({
|
|
92
|
+
optionsFromCliArgs: {},
|
|
93
|
+
optionsFromModule: { repoForkOwner: '', author: 'sqren' },
|
|
94
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"repoForkOwner\\" cannot be empty!"`);
|
|
98
95
|
});
|
|
99
96
|
it('throws for "author"', async () => {
|
|
100
|
-
await expect(() => (0, options_1.getOptions)(
|
|
97
|
+
await expect(() => (0, options_1.getOptions)({
|
|
98
|
+
optionsFromCliArgs: {},
|
|
99
|
+
optionsFromModule: { author: '' },
|
|
100
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"author\\" cannot be empty!"`);
|
|
101
101
|
});
|
|
102
102
|
it('throws for "accessToken"', async () => {
|
|
103
|
-
await expect(() => (0, options_1.getOptions)(
|
|
104
|
-
|
|
103
|
+
await expect(() => (0, options_1.getOptions)({
|
|
104
|
+
optionsFromCliArgs: {},
|
|
105
|
+
optionsFromModule: { accessToken: '' },
|
|
106
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
105
107
|
"Please update your config file: \\"/myHomeDir/.backport/config.json\\".
|
|
106
108
|
It must contain a valid \\"accessToken\\".
|
|
107
109
|
|
|
@@ -115,8 +117,7 @@ describe('getOptions', () => {
|
|
|
115
117
|
});
|
|
116
118
|
it('should throw if there are no remotes', async () => {
|
|
117
119
|
jest.spyOn(git, 'getRepoInfoFromGitRemotes').mockResolvedValue([]);
|
|
118
|
-
await expect(() => (0, options_1.getOptions)(
|
|
119
|
-
.toThrowErrorMatchingInlineSnapshot(`
|
|
120
|
+
await expect(() => (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
120
121
|
"Please specify a repository: \\"--repo elastic/kibana\\".
|
|
121
122
|
|
|
122
123
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
@@ -131,7 +132,10 @@ describe('getOptions', () => {
|
|
|
131
132
|
jest
|
|
132
133
|
.spyOn(git, 'getRepoInfoFromGitRemotes')
|
|
133
134
|
.mockResolvedValue([{ repoName: 'kibana', repoOwner: 'sqren' }]);
|
|
134
|
-
const options = await (0, options_1.getOptions)(
|
|
135
|
+
const options = await (0, options_1.getOptions)({
|
|
136
|
+
optionsFromCliArgs: {},
|
|
137
|
+
optionsFromModule: {},
|
|
138
|
+
});
|
|
135
139
|
expect(options.repoName).toBe('kibana');
|
|
136
140
|
expect(options.repoOwner).toBe('elastic');
|
|
137
141
|
});
|
|
@@ -139,7 +143,10 @@ describe('getOptions', () => {
|
|
|
139
143
|
});
|
|
140
144
|
it('reads options from remote config', async () => {
|
|
141
145
|
mockGithubConfigOptions({ hasRemoteConfig: true });
|
|
142
|
-
const options = await (0, options_1.getOptions)(
|
|
146
|
+
const options = await (0, options_1.getOptions)({
|
|
147
|
+
optionsFromCliArgs: {},
|
|
148
|
+
optionsFromModule: {},
|
|
149
|
+
});
|
|
143
150
|
expect(options.branchLabelMapping).toEqual({
|
|
144
151
|
'^v8.2.0$': 'option-from-remote',
|
|
145
152
|
});
|
|
@@ -147,17 +154,20 @@ describe('getOptions', () => {
|
|
|
147
154
|
});
|
|
148
155
|
it('should ensure that "backport" branch does not exist', async () => {
|
|
149
156
|
mockGithubConfigOptions({ hasBackportBranch: true });
|
|
150
|
-
await expect((0, options_1.getOptions)(
|
|
157
|
+
await expect((0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
151
158
|
});
|
|
152
159
|
it('should merge config options and module options', async () => {
|
|
153
160
|
mockGithubConfigOptions({});
|
|
154
161
|
const myFn = async () => true;
|
|
155
|
-
const options = await (0, options_1.getOptions)(
|
|
162
|
+
const options = await (0, options_1.getOptions)({
|
|
163
|
+
optionsFromCliArgs: {},
|
|
164
|
+
optionsFromModule: { autoFixConflicts: myFn },
|
|
165
|
+
});
|
|
156
166
|
expect(options.autoFixConflicts).toBe(myFn);
|
|
157
167
|
});
|
|
158
168
|
it('should call setAccessToken', async () => {
|
|
159
169
|
mockGithubConfigOptions({});
|
|
160
|
-
await (0, options_1.getOptions)(
|
|
170
|
+
await (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} });
|
|
161
171
|
expect(logger.setAccessToken).toHaveBeenCalledTimes(1);
|
|
162
172
|
});
|
|
163
173
|
it('should return options', async () => {
|
|
@@ -165,7 +175,10 @@ describe('getOptions', () => {
|
|
|
165
175
|
viewerLogin: 'john.diller',
|
|
166
176
|
defaultBranchRef: 'default-branch-from-github',
|
|
167
177
|
});
|
|
168
|
-
const options = await (0, options_1.getOptions)(
|
|
178
|
+
const options = await (0, options_1.getOptions)({
|
|
179
|
+
optionsFromCliArgs: {},
|
|
180
|
+
optionsFromModule: {},
|
|
181
|
+
});
|
|
169
182
|
expect(options).toEqual({
|
|
170
183
|
accessToken: 'abc',
|
|
171
184
|
assignees: [],
|
|
@@ -176,7 +189,6 @@ describe('getOptions', () => {
|
|
|
176
189
|
autoMergeMethod: 'merge',
|
|
177
190
|
backportBinary: 'backport',
|
|
178
191
|
cherrypickRef: true,
|
|
179
|
-
ci: false,
|
|
180
192
|
commitPaths: [],
|
|
181
193
|
cwd: expect.any(String),
|
|
182
194
|
dateSince: null,
|
|
@@ -186,11 +198,14 @@ describe('getOptions', () => {
|
|
|
186
198
|
fork: true,
|
|
187
199
|
gitHostname: 'github.com',
|
|
188
200
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
201
|
+
interactive: true,
|
|
189
202
|
maxNumber: 10,
|
|
190
203
|
multipleBranches: true,
|
|
191
204
|
multipleCommits: false,
|
|
192
205
|
noVerify: true,
|
|
193
|
-
|
|
206
|
+
publishStatusCommentOnAbort: false,
|
|
207
|
+
publishStatusCommentOnSuccess: true,
|
|
208
|
+
publishStatusCommentOnFailure: false,
|
|
194
209
|
repoForkOwner: 'john.diller',
|
|
195
210
|
repoName: 'kibana',
|
|
196
211
|
repoOwner: 'elastic',
|
|
@@ -208,11 +223,17 @@ describe('getOptions', () => {
|
|
|
208
223
|
mockGithubConfigOptions({ defaultBranchRef: 'some-default-branch' });
|
|
209
224
|
});
|
|
210
225
|
it('uses the `defaultBranchRef` as default', async () => {
|
|
211
|
-
const options = await (0, options_1.getOptions)(
|
|
226
|
+
const options = await (0, options_1.getOptions)({
|
|
227
|
+
optionsFromCliArgs: {},
|
|
228
|
+
optionsFromModule: {},
|
|
229
|
+
});
|
|
212
230
|
expect(options.sourceBranch).toBe('some-default-branch');
|
|
213
231
|
});
|
|
214
232
|
it('uses the sourceBranch given via cli instead of `defaultBranchRef`', async () => {
|
|
215
|
-
const options = await (0, options_1.getOptions)(
|
|
233
|
+
const options = await (0, options_1.getOptions)({
|
|
234
|
+
optionsFromCliArgs: { sourceBranch: 'cli-source-branch' },
|
|
235
|
+
optionsFromModule: {},
|
|
236
|
+
});
|
|
216
237
|
expect(options.sourceBranch).toBe('cli-source-branch');
|
|
217
238
|
});
|
|
218
239
|
});
|
|
@@ -221,16 +242,25 @@ describe('getOptions', () => {
|
|
|
221
242
|
mockGithubConfigOptions({});
|
|
222
243
|
});
|
|
223
244
|
it('is enabled by default', async () => {
|
|
224
|
-
const { fork } = await (0, options_1.getOptions)(
|
|
245
|
+
const { fork } = await (0, options_1.getOptions)({
|
|
246
|
+
optionsFromCliArgs: {},
|
|
247
|
+
optionsFromModule: {},
|
|
248
|
+
});
|
|
225
249
|
expect(fork).toBe(true);
|
|
226
250
|
});
|
|
227
|
-
it('can be disabled via
|
|
228
|
-
const { fork } = await (0, options_1.getOptions)(
|
|
251
|
+
it('can be disabled via cli', async () => {
|
|
252
|
+
const { fork } = await (0, options_1.getOptions)({
|
|
253
|
+
optionsFromCliArgs: { fork: false },
|
|
254
|
+
optionsFromModule: {},
|
|
255
|
+
});
|
|
229
256
|
expect(fork).toBe(false);
|
|
230
257
|
});
|
|
231
258
|
it('can be disabled via config file', async () => {
|
|
232
259
|
mockProjectConfig({ fork: false });
|
|
233
|
-
const { fork } = await (0, options_1.getOptions)(
|
|
260
|
+
const { fork } = await (0, options_1.getOptions)({
|
|
261
|
+
optionsFromCliArgs: {},
|
|
262
|
+
optionsFromModule: {},
|
|
263
|
+
});
|
|
234
264
|
expect(fork).toBe(false);
|
|
235
265
|
});
|
|
236
266
|
});
|
|
@@ -238,13 +268,19 @@ describe('getOptions', () => {
|
|
|
238
268
|
beforeEach(() => {
|
|
239
269
|
mockGithubConfigOptions({});
|
|
240
270
|
});
|
|
241
|
-
it('can be set via
|
|
242
|
-
const { reviewers } = await (0, options_1.getOptions)(
|
|
271
|
+
it('can be set via cli', async () => {
|
|
272
|
+
const { reviewers } = await (0, options_1.getOptions)({
|
|
273
|
+
optionsFromCliArgs: { reviewers: ['peter'] },
|
|
274
|
+
optionsFromModule: {},
|
|
275
|
+
});
|
|
243
276
|
expect(reviewers).toEqual(['peter']);
|
|
244
277
|
});
|
|
245
278
|
it('can be set via config file', async () => {
|
|
246
279
|
mockProjectConfig({ reviewers: ['john'] });
|
|
247
|
-
const { reviewers } = await (0, options_1.getOptions)(
|
|
280
|
+
const { reviewers } = await (0, options_1.getOptions)({
|
|
281
|
+
optionsFromCliArgs: {},
|
|
282
|
+
optionsFromModule: {},
|
|
283
|
+
});
|
|
248
284
|
expect(reviewers).toEqual(['john']);
|
|
249
285
|
});
|
|
250
286
|
});
|
|
@@ -253,15 +289,24 @@ describe('getOptions', () => {
|
|
|
253
289
|
mockGithubConfigOptions({});
|
|
254
290
|
});
|
|
255
291
|
it('is not enabled by default', async () => {
|
|
256
|
-
const { mainline } = await (0, options_1.getOptions)(
|
|
292
|
+
const { mainline } = await (0, options_1.getOptions)({
|
|
293
|
+
optionsFromCliArgs: {},
|
|
294
|
+
optionsFromModule: {},
|
|
295
|
+
});
|
|
257
296
|
expect(mainline).toBe(undefined);
|
|
258
297
|
});
|
|
259
298
|
it('can be set via `--mainline` flag', async () => {
|
|
260
|
-
const { mainline } = await (0, options_1.getOptions)(
|
|
299
|
+
const { mainline } = await (0, options_1.getOptions)({
|
|
300
|
+
optionsFromCliArgs: { mainline: 1 },
|
|
301
|
+
optionsFromModule: {},
|
|
302
|
+
});
|
|
261
303
|
expect(mainline).toBe(1);
|
|
262
304
|
});
|
|
263
305
|
it('accepts numeric values', async () => {
|
|
264
|
-
const { mainline } = await (0, options_1.getOptions)(
|
|
306
|
+
const { mainline } = await (0, options_1.getOptions)({
|
|
307
|
+
optionsFromCliArgs: { mainline: 2 },
|
|
308
|
+
optionsFromModule: {},
|
|
309
|
+
});
|
|
265
310
|
expect(mainline).toBe(2);
|
|
266
311
|
});
|
|
267
312
|
});
|
|
@@ -270,25 +315,33 @@ describe('getOptions', () => {
|
|
|
270
315
|
mockGithubConfigOptions({ viewerLogin: 'billy.bob' });
|
|
271
316
|
});
|
|
272
317
|
it('defaults to authenticated user', async () => {
|
|
273
|
-
const { author } = await (0, options_1.getOptions)(
|
|
318
|
+
const { author } = await (0, options_1.getOptions)({
|
|
319
|
+
optionsFromCliArgs: {},
|
|
320
|
+
optionsFromModule: {},
|
|
321
|
+
});
|
|
274
322
|
expect(author).toBe('billy.bob');
|
|
275
323
|
});
|
|
276
324
|
it('can be overridden via `--author` flag', async () => {
|
|
277
|
-
const { author } = await (0, options_1.getOptions)(
|
|
325
|
+
const { author } = await (0, options_1.getOptions)({
|
|
326
|
+
optionsFromCliArgs: { author: 'john.doe' },
|
|
327
|
+
optionsFromModule: {},
|
|
328
|
+
});
|
|
278
329
|
expect(author).toBe('john.doe');
|
|
279
330
|
});
|
|
280
|
-
it('can be reset via `--all` flag', async () => {
|
|
281
|
-
const { author } = await (0, options_1.getOptions)(['--all'], {});
|
|
282
|
-
expect(author).toBe(null);
|
|
283
|
-
});
|
|
284
331
|
it('can be reset via config file (similar to `--all` flag)', async () => {
|
|
285
332
|
mockProjectConfig({ author: null });
|
|
286
|
-
const { author } = await (0, options_1.getOptions)(
|
|
333
|
+
const { author } = await (0, options_1.getOptions)({
|
|
334
|
+
optionsFromCliArgs: {},
|
|
335
|
+
optionsFromModule: {},
|
|
336
|
+
});
|
|
287
337
|
expect(author).toBe(null);
|
|
288
338
|
});
|
|
289
339
|
it('can be overridden via config file', async () => {
|
|
290
340
|
mockProjectConfig({ author: 'jane.doe' });
|
|
291
|
-
const { author } = await (0, options_1.getOptions)(
|
|
341
|
+
const { author } = await (0, options_1.getOptions)({
|
|
342
|
+
optionsFromCliArgs: {},
|
|
343
|
+
optionsFromModule: {},
|
|
344
|
+
});
|
|
292
345
|
expect(author).toBe('jane.doe');
|
|
293
346
|
});
|
|
294
347
|
});
|
|
@@ -297,21 +350,26 @@ describe('getOptions', () => {
|
|
|
297
350
|
mockGithubConfigOptions({});
|
|
298
351
|
});
|
|
299
352
|
it('should default to true', async () => {
|
|
300
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(
|
|
353
|
+
const { cherrypickRef } = await (0, options_1.getOptions)({
|
|
354
|
+
optionsFromCliArgs: {},
|
|
355
|
+
optionsFromModule: {},
|
|
356
|
+
});
|
|
301
357
|
expect(cherrypickRef).toBe(true);
|
|
302
358
|
});
|
|
303
|
-
it('should negate with `noCherrypickRef` cli arg', async () => {
|
|
304
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(['--no-cherrypick-ref'], {});
|
|
305
|
-
expect(cherrypickRef).toBe(false);
|
|
306
|
-
});
|
|
307
359
|
it('should be settable via config file', async () => {
|
|
308
360
|
mockProjectConfig({ cherrypickRef: false });
|
|
309
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(
|
|
361
|
+
const { cherrypickRef } = await (0, options_1.getOptions)({
|
|
362
|
+
optionsFromCliArgs: {},
|
|
363
|
+
optionsFromModule: {},
|
|
364
|
+
});
|
|
310
365
|
expect(cherrypickRef).toBe(false);
|
|
311
366
|
});
|
|
312
367
|
it('cli args overwrites config', async () => {
|
|
313
368
|
mockProjectConfig({ cherrypickRef: false });
|
|
314
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(
|
|
369
|
+
const { cherrypickRef } = await (0, options_1.getOptions)({
|
|
370
|
+
optionsFromCliArgs: { cherrypickRef: true },
|
|
371
|
+
optionsFromModule: {},
|
|
372
|
+
});
|
|
315
373
|
expect(cherrypickRef).toBe(true);
|
|
316
374
|
});
|
|
317
375
|
});
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
+
import { BackportError } from './lib/BackportError';
|
|
2
|
+
import { GitConfigAuthor } from './lib/getGitConfigAuthor';
|
|
3
|
+
import { Commit } from './lib/sourceCommit/parseSourceCommit';
|
|
1
4
|
import { ValidConfigOptions } from './options/options';
|
|
2
|
-
|
|
3
|
-
import { Commit } from './services/sourceCommit/parseSourceCommit';
|
|
4
|
-
import { GitConfigAuthor } from './ui/getGitConfigAuthor';
|
|
5
|
-
export declare type Result = {
|
|
5
|
+
export declare type SuccessResult = {
|
|
6
6
|
status: 'success';
|
|
7
7
|
didUpdate: boolean;
|
|
8
8
|
targetBranch: string;
|
|
9
9
|
pullRequestUrl: string;
|
|
10
10
|
pullRequestNumber: number;
|
|
11
|
-
}
|
|
11
|
+
};
|
|
12
|
+
export declare type HandledErrorResult = {
|
|
12
13
|
status: 'handled-error';
|
|
13
14
|
targetBranch: string;
|
|
14
|
-
error:
|
|
15
|
-
}
|
|
15
|
+
error: BackportError;
|
|
16
|
+
};
|
|
17
|
+
export declare type UnhandledErrorResult = {
|
|
16
18
|
status: 'unhandled-error';
|
|
17
19
|
targetBranch: string;
|
|
18
20
|
error: Error;
|
|
19
21
|
};
|
|
22
|
+
export declare type Result = SuccessResult | HandledErrorResult | UnhandledErrorResult;
|
|
20
23
|
export declare function runSequentially({ options, commits, targetBranches, gitConfigAuthor, }: {
|
|
21
24
|
options: ValidConfigOptions;
|
|
22
25
|
commits: Commit[];
|
package/dist/runSequentially.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runSequentially = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
const BackportError_1 = require("./lib/BackportError");
|
|
5
|
+
const cherrypickAndCreateTargetPullRequest_1 = require("./lib/cherrypickAndCreateTargetPullRequest");
|
|
6
|
+
const logger_1 = require("./lib/logger");
|
|
7
|
+
const sequentially_1 = require("./lib/sequentially");
|
|
8
8
|
async function runSequentially({ options, commits, targetBranches, gitConfigAuthor, }) {
|
|
9
9
|
logger_1.logger.verbose('Backport options', options);
|
|
10
10
|
const results = [];
|
|
@@ -26,7 +26,7 @@ async function runSequentially({ options, commits, targetBranches, gitConfigAuth
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
catch (e) {
|
|
29
|
-
const isHandledError = e instanceof
|
|
29
|
+
const isHandledError = e instanceof BackportError_1.BackportError;
|
|
30
30
|
if (isHandledError) {
|
|
31
31
|
results.push({
|
|
32
32
|
targetBranch,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.postinstall = void 0;
|
|
4
|
+
const env_1 = require("../lib/env");
|
|
5
|
+
const logger_1 = require("../lib/logger");
|
|
4
6
|
const globalConfig_1 = require("../options/config/globalConfig");
|
|
5
|
-
const env_1 = require("../services/env");
|
|
6
|
-
const logger_1 = require("../services/logger");
|
|
7
7
|
async function postinstall() {
|
|
8
8
|
try {
|
|
9
|
-
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
9
|
+
const globalConfigPath = (0, env_1.getGlobalConfigPath)(undefined);
|
|
10
10
|
const didCreate = await (0, globalConfig_1.createGlobalConfigAndFolderIfNotExist)(globalConfigPath);
|
|
11
11
|
if (didCreate) {
|
|
12
12
|
(0, logger_1.consoleLog)(`Global config successfully created in ${globalConfigPath}`);
|
|
@@ -27,8 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const os_1 = __importDefault(require("os"));
|
|
30
|
+
const logger = __importStar(require("../lib/logger"));
|
|
30
31
|
const globalConfig = __importStar(require("../options/config/globalConfig"));
|
|
31
|
-
const logger = __importStar(require("../services/logger"));
|
|
32
32
|
const postinstall_1 = require("./postinstall");
|
|
33
33
|
describe('postinstall', () => {
|
|
34
34
|
beforeEach(() => {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Commit } from './sourceCommit/parseSourceCommit';
|
|
2
|
+
declare type ErrorContext = {
|
|
3
|
+
code: 'merge-conflict-exception';
|
|
4
|
+
conflictingFiles: string[];
|
|
5
|
+
commitsWithoutBackports: {
|
|
6
|
+
formatted: string;
|
|
7
|
+
commit: Commit;
|
|
8
|
+
}[];
|
|
9
|
+
} | {
|
|
10
|
+
code: 'message-only-exception';
|
|
11
|
+
message: string;
|
|
12
|
+
} | {
|
|
13
|
+
code: 'no-branches-exception' | 'abort-exception';
|
|
14
|
+
};
|
|
15
|
+
export declare class BackportError extends Error {
|
|
16
|
+
errorContext: ErrorContext;
|
|
17
|
+
constructor(errorContextOrString: ErrorContext | string);
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackportError = void 0;
|
|
4
|
+
function getMessage(errorContext) {
|
|
5
|
+
switch (errorContext.code) {
|
|
6
|
+
case 'merge-conflict-exception':
|
|
7
|
+
return `Commit could not be cherrypicked due to conflicts in: ${errorContext.conflictingFiles.join(',')}`;
|
|
8
|
+
case 'no-branches-exception':
|
|
9
|
+
return 'There are no branches to backport to. Aborting.';
|
|
10
|
+
case 'abort-exception':
|
|
11
|
+
return 'Aborted';
|
|
12
|
+
case 'message-only-exception':
|
|
13
|
+
return errorContext.message;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class BackportError extends Error {
|
|
17
|
+
constructor(errorContextOrString) {
|
|
18
|
+
const errorContext = typeof errorContextOrString === 'string'
|
|
19
|
+
? { code: 'message-only-exception', message: errorContextOrString }
|
|
20
|
+
: errorContextOrString;
|
|
21
|
+
const message = getMessage(errorContext);
|
|
22
|
+
super(message);
|
|
23
|
+
Error.captureStackTrace(this, BackportError);
|
|
24
|
+
this.name = 'BackportError';
|
|
25
|
+
this.message = message;
|
|
26
|
+
this.errorContext = errorContext;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.BackportError = BackportError;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Commit } from './sourceCommit/parseSourceCommit';
|
|
2
|
+
declare type ErrorContext = {
|
|
3
|
+
code: 'merge-conflict-exception';
|
|
4
|
+
conflictingFiles: string[];
|
|
5
|
+
commitsWithoutBackports: {
|
|
6
|
+
formatted: string;
|
|
7
|
+
commit: Commit;
|
|
8
|
+
}[];
|
|
9
|
+
} | {
|
|
10
|
+
code: 'message-only-exception';
|
|
11
|
+
message: string;
|
|
12
|
+
} | {
|
|
13
|
+
code: 'no-branches-exception' | 'abort-exception';
|
|
14
|
+
};
|
|
15
|
+
export declare class BackportError extends Error {
|
|
16
|
+
errorContext: ErrorContext;
|
|
17
|
+
constructor(errorContextOrString: ErrorContext | string);
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackportError = void 0;
|
|
4
|
+
function getMessage(errorContext) {
|
|
5
|
+
switch (errorContext.code) {
|
|
6
|
+
case 'merge-conflict-exception':
|
|
7
|
+
return `Commit could not be cherrypicked due to conflicts in: ${errorContext.conflictingFiles.join(',')}`;
|
|
8
|
+
case 'no-branches-exception':
|
|
9
|
+
return 'There are no branches to backport to. Aborting.';
|
|
10
|
+
case 'abort-exception':
|
|
11
|
+
return 'Aborted';
|
|
12
|
+
case 'message-only-exception':
|
|
13
|
+
return errorContext.message;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class BackportError extends Error {
|
|
17
|
+
constructor(errorContextOrString) {
|
|
18
|
+
const errorContext = typeof errorContextOrString === 'string'
|
|
19
|
+
? { code: 'message-only-exception', message: errorContextOrString }
|
|
20
|
+
: errorContextOrString;
|
|
21
|
+
const message = getMessage(errorContext);
|
|
22
|
+
super(message);
|
|
23
|
+
Error.captureStackTrace(this, BackportError);
|
|
24
|
+
this.name = 'BackportError';
|
|
25
|
+
this.message = message;
|
|
26
|
+
this.errorContext = errorContext;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.BackportError = BackportError;
|
|
@@ -12,7 +12,7 @@ declare type ErrorContext = {
|
|
|
12
12
|
} | {
|
|
13
13
|
code: 'no-branches-exception' | 'abort-exception';
|
|
14
14
|
};
|
|
15
|
-
export declare class
|
|
15
|
+
export declare class BackportError extends Error {
|
|
16
16
|
errorContext: ErrorContext;
|
|
17
17
|
constructor(errorContextOrString: ErrorContext | string);
|
|
18
18
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.BackportError = void 0;
|
|
4
4
|
function getMessage(errorContext) {
|
|
5
5
|
switch (errorContext.code) {
|
|
6
6
|
case 'merge-conflict-exception':
|
|
@@ -13,17 +13,17 @@ function getMessage(errorContext) {
|
|
|
13
13
|
return errorContext.message;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
class
|
|
16
|
+
class BackportError extends Error {
|
|
17
17
|
constructor(errorContextOrString) {
|
|
18
18
|
const errorContext = typeof errorContextOrString === 'string'
|
|
19
19
|
? { code: 'message-only-exception', message: errorContextOrString }
|
|
20
20
|
: errorContextOrString;
|
|
21
21
|
const message = getMessage(errorContext);
|
|
22
22
|
super(message);
|
|
23
|
-
Error.captureStackTrace(this,
|
|
24
|
-
this.name = '
|
|
23
|
+
Error.captureStackTrace(this, BackportError);
|
|
24
|
+
this.name = 'BackportError';
|
|
25
25
|
this.message = message;
|
|
26
26
|
this.errorContext = errorContext;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
exports.
|
|
29
|
+
exports.BackportError = BackportError;
|
package/dist/services/git.js
CHANGED
|
@@ -5,7 +5,7 @@ const path_1 = require("path");
|
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
6
|
const ora_1 = require("../ui/ora");
|
|
7
7
|
const filterEmpty_1 = require("../utils/filterEmpty");
|
|
8
|
-
const
|
|
8
|
+
const BackportError_1 = require("./BackportError");
|
|
9
9
|
const child_process_promisified_1 = require("./child-process-promisified");
|
|
10
10
|
const env_1 = require("./env");
|
|
11
11
|
const commitFormatters_1 = require("./github/commitFormatters");
|
|
@@ -240,17 +240,17 @@ async function cherrypick({ options, sha, mergedTargetPullRequest, commitAuthor,
|
|
|
240
240
|
if (isSpawnError) {
|
|
241
241
|
// missing `mainline` option
|
|
242
242
|
if (e.message.includes('is a merge but no -m option was given')) {
|
|
243
|
-
throw new
|
|
243
|
+
throw new BackportError_1.BackportError('Cherrypick failed because the selected commit was a merge commit. Please try again by specifying the parent with the `mainline` argument:\n\n> backport --mainline\n\nor:\n\n> backport --mainline <parent-number>\n\nOr refer to the git documentation for more information: https://git-scm.com/docs/git-cherry-pick#Documentation/git-cherry-pick.txt---mainlineparent-number');
|
|
244
244
|
}
|
|
245
245
|
// commit was already backported
|
|
246
246
|
if (e.message.includes('The previous cherry-pick is now empty')) {
|
|
247
247
|
const shortSha = (0, commitFormatters_1.getShortSha)(sha);
|
|
248
|
-
throw new
|
|
248
|
+
throw new BackportError_1.BackportError(`Cherrypick failed because the selected commit (${shortSha}) is empty. ${mergedTargetPullRequest?.url
|
|
249
249
|
? `It looks like the commit was already backported in ${mergedTargetPullRequest.url}`
|
|
250
250
|
: 'Did you already backport this commit? '}`);
|
|
251
251
|
}
|
|
252
252
|
if (e.message.includes(`bad object ${sha}`)) {
|
|
253
|
-
throw new
|
|
253
|
+
throw new BackportError_1.BackportError(`Cherrypick failed because commit "${sha}" was not found`);
|
|
254
254
|
}
|
|
255
255
|
const isCherryPickError = e.context.cmdArgs.includes('cherry-pick') && e.context.code > 0;
|
|
256
256
|
if (isCherryPickError) {
|
|
@@ -383,7 +383,7 @@ async function createBackportBranch({ options, targetBranch, backportBranch, })
|
|
|
383
383
|
.toLowerCase()
|
|
384
384
|
.includes(`is not a commit and a branch '${backportBranch}' cannot be created from it`);
|
|
385
385
|
if (isBranchInvalid) {
|
|
386
|
-
throw new
|
|
386
|
+
throw new BackportError_1.BackportError(`The branch "${targetBranch}" is invalid or doesn't exist`);
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
throw e;
|
|
@@ -419,11 +419,11 @@ async function pushBackportBranch({ options, backportBranch, }) {
|
|
|
419
419
|
spinner.fail();
|
|
420
420
|
if (e instanceof child_process_promisified_1.SpawnError &&
|
|
421
421
|
e.context.stderr.toLowerCase().includes(`repository not found`)) {
|
|
422
|
-
throw new
|
|
422
|
+
throw new BackportError_1.BackportError(`Error pushing to https://github.com/${repoForkOwner}/${options.repoName}. Repository does not exist. Either fork the repository (https://github.com/${options.repoOwner}/${options.repoName}) or disable fork mode via "--no-fork".\nRead more about fork mode in the docs: https://github.com/sqren/backport/blob/main/docs/configuration.md#fork`);
|
|
423
423
|
}
|
|
424
424
|
if (e instanceof child_process_promisified_1.SpawnError &&
|
|
425
425
|
e.context.stderr.includes(`could not read Username for`)) {
|
|
426
|
-
throw new
|
|
426
|
+
throw new BackportError_1.BackportError(`Invalid credentials: ${e.message}`);
|
|
427
427
|
}
|
|
428
428
|
throw e;
|
|
429
429
|
}
|
|
@@ -4,7 +4,7 @@ exports.getTitle = exports.getPullRequestBody = exports.createPullRequest = void
|
|
|
4
4
|
const rest_1 = require("@octokit/rest");
|
|
5
5
|
const ora_1 = require("../../../ui/ora");
|
|
6
6
|
const packageVersion_1 = require("../../../utils/packageVersion");
|
|
7
|
-
const
|
|
7
|
+
const BackportError_1 = require("../../BackportError");
|
|
8
8
|
const logger_1 = require("../../logger");
|
|
9
9
|
const commitFormatters_1 = require("../commitFormatters");
|
|
10
10
|
const fetchExistingPullRequest_1 = require("../v4/fetchExistingPullRequest");
|
|
@@ -48,7 +48,7 @@ async function createPullRequest({ options, prPayload, }) {
|
|
|
48
48
|
// swallow error
|
|
49
49
|
}
|
|
50
50
|
spinner.fail();
|
|
51
|
-
throw new
|
|
51
|
+
throw new BackportError_1.BackportError(
|
|
52
52
|
//@ts-expect-error
|
|
53
53
|
`Could not create pull request: ${(0, getGithubV3ErrorMessage_1.getGithubV3ErrorMessage)(e)}`);
|
|
54
54
|
}
|