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
|
@@ -4,7 +4,7 @@ exports.getCommentBody = exports.createStatusComment = void 0;
|
|
|
4
4
|
const rest_1 = require("@octokit/rest");
|
|
5
5
|
const packageVersion_1 = require("../../../utils/packageVersion");
|
|
6
6
|
const redact_1 = require("../../../utils/redact");
|
|
7
|
-
const
|
|
7
|
+
const BackportError_1 = require("../../BackportError");
|
|
8
8
|
const logger_1 = require("../../logger");
|
|
9
9
|
const commitFormatters_1 = require("../commitFormatters");
|
|
10
10
|
async function createStatusComment({ options, backportResponse, }) {
|
|
@@ -87,7 +87,7 @@ ${manualBackportCommand}${questionsAndLinkToBackport}${packageVersionSection}`;
|
|
|
87
87
|
`[<img src="https://img.shields.io/github/pulls/detail/state/${repoOwner}/${repoName}/${result.pullRequestNumber}">](${result.pullRequestUrl})`,
|
|
88
88
|
];
|
|
89
89
|
}
|
|
90
|
-
if (result.error instanceof
|
|
90
|
+
if (result.error instanceof BackportError_1.BackportError &&
|
|
91
91
|
result.error.errorContext.code === 'merge-conflict-exception') {
|
|
92
92
|
const unmergedBackports = result.error.errorContext.commitsWithoutBackports.map((c) => {
|
|
93
93
|
return ` - [${(0, commitFormatters_1.getFirstLine)(c.commit.sourceCommit.message)}](${c.commit.sourcePullRequest?.url})`;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const nock_1 = __importDefault(require("nock"));
|
|
7
|
-
const
|
|
7
|
+
const BackportError_1 = require("../../BackportError");
|
|
8
8
|
const createStatusComment_1 = require("./createStatusComment");
|
|
9
9
|
describe('createStatusComment', () => {
|
|
10
10
|
it('redacts accessToken if it is included in the error message', async () => {
|
|
@@ -269,7 +269,7 @@ describe('getCommentBody', () => {
|
|
|
269
269
|
{
|
|
270
270
|
status: 'failure',
|
|
271
271
|
targetBranch: '7.1',
|
|
272
|
-
error: new
|
|
272
|
+
error: new BackportError_1.BackportError({
|
|
273
273
|
code: 'merge-conflict-exception',
|
|
274
274
|
conflictingFiles: ['readme.md'],
|
|
275
275
|
commitsWithoutBackports: [
|
|
@@ -327,7 +327,7 @@ describe('getCommentBody', () => {
|
|
|
327
327
|
{
|
|
328
328
|
status: 'failure',
|
|
329
329
|
targetBranch: '7.2',
|
|
330
|
-
error: new
|
|
330
|
+
error: new BackportError_1.BackportError({
|
|
331
331
|
code: 'merge-conflict-exception',
|
|
332
332
|
conflictingFiles: ['my-file.txt'],
|
|
333
333
|
commitsWithoutBackports: [],
|
|
@@ -379,7 +379,8 @@ describe('getCommentBody', () => {
|
|
|
379
379
|
backportResponse: {
|
|
380
380
|
status: 'aborted',
|
|
381
381
|
commits: [],
|
|
382
|
-
error: new
|
|
382
|
+
error: new BackportError_1.BackportError({ code: 'no-branches-exception' }),
|
|
383
|
+
errorMessage: 'my message',
|
|
383
384
|
},
|
|
384
385
|
});
|
|
385
386
|
it('posts a comment when running on CI', () => {
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getQueryName = exports.GithubV4Exception = exports.apiRequestV4 = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const printer_1 = require("graphql/language/printer");
|
|
9
|
-
const
|
|
9
|
+
const BackportError_1 = require("../../BackportError");
|
|
10
10
|
const logger_1 = require("../../logger");
|
|
11
11
|
async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graphql', accessToken, query, variables, }) {
|
|
12
12
|
try {
|
|
@@ -57,7 +57,7 @@ class GithubV4Exception extends Error {
|
|
|
57
57
|
.join(',');
|
|
58
58
|
const message = `${errorMessage ?? githubMessage ?? 'Unknown error'} (Github API v4)`;
|
|
59
59
|
super(message);
|
|
60
|
-
Error.captureStackTrace(this,
|
|
60
|
+
Error.captureStackTrace(this, BackportError_1.BackportError);
|
|
61
61
|
this.name = 'GithubV4Exception';
|
|
62
62
|
this.message = message;
|
|
63
63
|
this.githubResponse = { ...githubResponse, request: undefined };
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
7
7
|
const nock_1 = __importDefault(require("nock"));
|
|
8
8
|
const nockHelpers_1 = require("../../../test/nockHelpers");
|
|
9
|
-
const
|
|
9
|
+
const BackportError_1 = require("../../BackportError");
|
|
10
10
|
const apiRequestV4_1 = require("./apiRequestV4");
|
|
11
11
|
describe('apiRequestV4', () => {
|
|
12
12
|
afterEach(() => {
|
|
@@ -78,7 +78,7 @@ describe('apiRequestV4', () => {
|
|
|
78
78
|
variables: {
|
|
79
79
|
foo: 'bar',
|
|
80
80
|
},
|
|
81
|
-
})).rejects.toThrowError(new
|
|
81
|
+
})).rejects.toThrowError(new BackportError_1.BackportError(`some error,some other error (Github API v4)`));
|
|
82
82
|
});
|
|
83
83
|
});
|
|
84
84
|
describe('when request fails without error messages', () => {
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fetchCommitByPullNumber = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
-
const
|
|
8
|
+
const BackportError_1 = require("../../../BackportError");
|
|
9
9
|
const remoteConfig_1 = require("../../../remoteConfig");
|
|
10
10
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
11
11
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
@@ -47,11 +47,11 @@ async function fetchCommitByPullNumber(options) {
|
|
|
47
47
|
}
|
|
48
48
|
const pullRequestNode = res.repository.pullRequest;
|
|
49
49
|
if (!pullRequestNode) {
|
|
50
|
-
throw new
|
|
50
|
+
throw new BackportError_1.BackportError(`The PR #${pullNumber} does not exist`);
|
|
51
51
|
}
|
|
52
52
|
const sourceCommit = pullRequestNode.mergeCommit;
|
|
53
53
|
if (sourceCommit === null) {
|
|
54
|
-
throw new
|
|
54
|
+
throw new BackportError_1.BackportError(`The PR #${pullNumber} is not merged`);
|
|
55
55
|
}
|
|
56
56
|
return (0, parseSourceCommit_1.parseSourceCommit)({ options, sourceCommit });
|
|
57
57
|
}
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fetchCommitBySha = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
-
const
|
|
8
|
+
const BackportError_1 = require("../../../BackportError");
|
|
9
9
|
const remoteConfig_1 = require("../../../remoteConfig");
|
|
10
10
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
11
11
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
@@ -41,7 +41,7 @@ async function fetchCommitBySha(options) {
|
|
|
41
41
|
}
|
|
42
42
|
const sourceCommit = res.repository.object;
|
|
43
43
|
if (!sourceCommit) {
|
|
44
|
-
throw new
|
|
44
|
+
throw new BackportError_1.BackportError(`No commit found on branch "${sourceBranch}" with sha "${sha}"`);
|
|
45
45
|
}
|
|
46
46
|
return (0, parseSourceCommit_1.parseSourceCommit)({ options, sourceCommit });
|
|
47
47
|
}
|
|
@@ -8,7 +8,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
10
|
const filterUnmergedCommits_1 = require("../../../../utils/filterUnmergedCommits");
|
|
11
|
-
const
|
|
11
|
+
const BackportError_1 = require("../../../BackportError");
|
|
12
12
|
const remoteConfig_1 = require("../../../remoteConfig");
|
|
13
13
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
14
14
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
@@ -82,7 +82,7 @@ async function fetchCommitsByAuthor(options) {
|
|
|
82
82
|
: commitPaths.map((commitPath) => fetchByCommitPath({ options, authorId, commitPath })));
|
|
83
83
|
// we only need to check if the first item is `null` (if the first is `null` they all are)
|
|
84
84
|
if (responses[0].repository.ref === null) {
|
|
85
|
-
throw new
|
|
85
|
+
throw new BackportError_1.BackportError(`The upstream branch "${sourceBranch}" does not exist. Try specifying a different branch with "--source-branch <your-branch>"`);
|
|
86
86
|
}
|
|
87
87
|
const commits = responses
|
|
88
88
|
.flatMap((res) => {
|
|
@@ -98,7 +98,7 @@ async function fetchCommitsByAuthor(options) {
|
|
|
98
98
|
const errorText = options.author
|
|
99
99
|
? `There are no commits by "${options.author}" in this repository${pathText}. Try with \`--all\` for commits by all users or \`--author=<username>\` for commits from a specific user`
|
|
100
100
|
: `There are no commits in this repository${pathText}`;
|
|
101
|
-
throw new
|
|
101
|
+
throw new BackportError_1.BackportError(errorText);
|
|
102
102
|
}
|
|
103
103
|
const commitsUnique = (0, lodash_1.uniqBy)(commits, (c) => c.sourceCommit.sha);
|
|
104
104
|
const commitsSorted = (0, lodash_1.orderBy)(commitsUnique, (c) => c.sourceCommit.committedDate, 'desc');
|
|
@@ -7,7 +7,7 @@ exports.fetchPullRequestsBySearchQuery = void 0;
|
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
9
|
const filterUnmergedCommits_1 = require("../../../../utils/filterUnmergedCommits");
|
|
10
|
-
const
|
|
10
|
+
const BackportError_1 = require("../../../BackportError");
|
|
11
11
|
const remoteConfig_1 = require("../../../remoteConfig");
|
|
12
12
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
13
13
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
@@ -59,7 +59,7 @@ async function fetchPullRequestsBySearchQuery(options) {
|
|
|
59
59
|
const errorText = author
|
|
60
60
|
? `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`
|
|
61
61
|
: `No commits found for query:\n ${searchQuery}`;
|
|
62
|
-
throw new
|
|
62
|
+
throw new BackportError_1.BackportError(errorText);
|
|
63
63
|
}
|
|
64
64
|
if (options.onlyMissing) {
|
|
65
65
|
return commits.filter(filterUnmergedCommits_1.filterUnmergedCommits);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOptionsFromGithub = void 0;
|
|
4
|
-
const
|
|
4
|
+
const BackportError_1 = require("../../../BackportError");
|
|
5
5
|
const git_1 = require("../../../git");
|
|
6
6
|
const logger_1 = require("../../../logger");
|
|
7
7
|
const remoteConfig_1 = require("../../../remoteConfig");
|
|
@@ -28,7 +28,7 @@ async function getOptionsFromGithub(options) {
|
|
|
28
28
|
}
|
|
29
29
|
// it is not possible to have a branch named "backport"
|
|
30
30
|
if (res.repository.illegalBackportBranch) {
|
|
31
|
-
throw new
|
|
31
|
+
throw new BackportError_1.BackportError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
32
32
|
}
|
|
33
33
|
const remoteConfig = await getRemoteConfigFileOptions(res, options.cwd, options.skipRemoteConfig);
|
|
34
34
|
return {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.throwOnInvalidAccessToken = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const maybe_1 = require("../../../utils/maybe");
|
|
6
|
-
const
|
|
6
|
+
const BackportError_1 = require("../../BackportError");
|
|
7
7
|
const env_1 = require("../../env");
|
|
8
8
|
function throwOnInvalidAccessToken({ error, repoOwner, repoName, }) {
|
|
9
9
|
function getSSOAuthUrl(ssoHeader) {
|
|
@@ -23,21 +23,21 @@ function throwOnInvalidAccessToken({ error, repoOwner, repoName, }) {
|
|
|
23
23
|
const hasRequiredScopes = (0, lodash_1.isEmpty)((0, lodash_1.difference)(requiredScopes.split(','), grantedScopes.split(',')));
|
|
24
24
|
// user does not have permission to the repo
|
|
25
25
|
if (!hasRequiredScopes) {
|
|
26
|
-
throw new
|
|
26
|
+
throw new BackportError_1.BackportError(`You do not have access to the repository "${repoOwner}/${repoName}". Please make sure your access token has the required scopes.\n\nRequired scopes: ${requiredScopes}\nAccess token scopes: ${grantedScopes}`);
|
|
27
27
|
}
|
|
28
28
|
// repo does not exist
|
|
29
|
-
throw new
|
|
29
|
+
throw new BackportError_1.BackportError(`The repository "${repoOwner}/${repoName}" doesn't exist`);
|
|
30
30
|
}
|
|
31
31
|
const repoAccessForbidden = error.githubResponse.data.errors?.some((error) => error.type === 'FORBIDDEN');
|
|
32
32
|
const ssoAuthUrl = getSSOAuthUrl(ssoHeader);
|
|
33
33
|
// user does not have permissions
|
|
34
34
|
if (repoAccessForbidden && ssoAuthUrl) {
|
|
35
|
-
throw new
|
|
35
|
+
throw new BackportError_1.BackportError(`Please follow the link to authorize your personal access token with SSO:\n\n${ssoAuthUrl}`);
|
|
36
36
|
}
|
|
37
37
|
break;
|
|
38
38
|
}
|
|
39
39
|
case 401:
|
|
40
|
-
throw new
|
|
40
|
+
throw new BackportError_1.BackportError(`Please check your access token and make sure it is valid.\nConfig: ${(0, env_1.getGlobalConfigPath)()}`);
|
|
41
41
|
default:
|
|
42
42
|
return undefined;
|
|
43
43
|
}
|
package/dist/state.d.ts
ADDED
|
File without changes
|
package/dist/state.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
7
|
-
const child_process_promisified_1 = require("../../../
|
|
7
|
+
const child_process_promisified_1 = require("../../../lib/child-process-promisified");
|
|
8
8
|
const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
9
9
|
const sandbox_1 = require("../../sandbox");
|
|
10
10
|
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
@@ -50,7 +50,7 @@ describe('commit author', () => {
|
|
|
50
50
|
'--branch=production',
|
|
51
51
|
'--pr=2',
|
|
52
52
|
'--dry-run',
|
|
53
|
-
], {
|
|
53
|
+
], { cwd: sourceRepo, showOra: true });
|
|
54
54
|
const { authorEmail, authorName } = await getCommitAuthor({
|
|
55
55
|
cwd: backportRepo,
|
|
56
56
|
});
|
|
@@ -66,7 +66,7 @@ describe('commit author', () => {
|
|
|
66
66
|
'--dry-run',
|
|
67
67
|
'--gitAuthorName="Donald Duck"',
|
|
68
68
|
'--gitAuthorEmail=duck@disney.com',
|
|
69
|
-
], {
|
|
69
|
+
], { cwd: sourceRepo, showOra: true });
|
|
70
70
|
const { authorEmail, authorName } = await getCommitAuthor({
|
|
71
71
|
cwd: backportRepo,
|
|
72
72
|
});
|
|
@@ -81,7 +81,7 @@ describe('commit author', () => {
|
|
|
81
81
|
'--pr=2',
|
|
82
82
|
'--dry-run',
|
|
83
83
|
'--reset-author',
|
|
84
|
-
], {
|
|
84
|
+
], { cwd: sourceRepo, showOra: true });
|
|
85
85
|
const { authorEmail, authorName } = await getCommitAuthor({
|
|
86
86
|
cwd: backportRepo,
|
|
87
87
|
});
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const child_process_promisified_1 = require("../../../
|
|
3
|
+
const child_process_promisified_1 = require("../../../lib/child-process-promisified");
|
|
4
4
|
const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
5
5
|
const sandbox_1 = require("../../sandbox");
|
|
6
6
|
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
7
7
|
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
8
8
|
describe('different-merge-strategies', () => {
|
|
9
9
|
it('list all commits regardless how they were merged', async () => {
|
|
10
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
10
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
11
11
|
'--branch=foo',
|
|
12
12
|
'--repo=backport-org/different-merge-strategies',
|
|
13
13
|
`--accessToken=${accessToken}`,
|
|
14
14
|
'-n=20',
|
|
15
|
-
], { waitForString: 'Select commit' });
|
|
15
|
+
], { waitForString: 'Select commit', timeoutSeconds: 4 });
|
|
16
16
|
expect(output).toMatchInlineSnapshot(`
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
"? Select commit (Use arrow keys)
|
|
18
|
+
❯ 1. Merge pull request #9 from backport-org/many-merge-commits
|
|
19
|
+
2. Merge strategy: Eighth of many merges
|
|
20
|
+
3. Merge strategy: Seventh of many merges
|
|
21
|
+
4. Merge strategy: Sixth of many merges
|
|
22
|
+
5. Merge strategy: Fifth of many merges
|
|
23
|
+
6. Merge strategy: Fourth of many merges
|
|
24
|
+
7. Merge strategy: Third of many merges
|
|
25
|
+
8. Merge strategy: Second of many merges
|
|
26
|
+
9. Merge strategy: First of many merges
|
|
27
|
+
10.Using squash to merge commits (#3) 7.x
|
|
28
|
+
11.Rebase strategy: Second commit 7.x
|
|
29
|
+
12.Rebase strategy: First commit
|
|
30
|
+
13.Merge pull request #1 from backport-org/merge-strategy
|
|
31
|
+
14.Merge strategy: Second commit
|
|
32
|
+
15.Merge strategy: First commit
|
|
33
|
+
16.Initial commit"
|
|
34
|
+
`);
|
|
35
35
|
});
|
|
36
36
|
describe('when selecting a merge commit', () => {
|
|
37
37
|
let output;
|
|
@@ -39,20 +39,22 @@ describe('different-merge-strategies', () => {
|
|
|
39
39
|
beforeAll(async () => {
|
|
40
40
|
sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
41
41
|
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
42
|
-
|
|
42
|
+
const res = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
43
43
|
'--branch=7.x',
|
|
44
44
|
'--repo=backport-org/different-merge-strategies',
|
|
45
45
|
`--accessToken=${accessToken}`,
|
|
46
46
|
`--dir=${sandboxPath}`,
|
|
47
47
|
'--pr=9',
|
|
48
48
|
'--dry-run',
|
|
49
|
-
], {
|
|
49
|
+
], { showOra: true });
|
|
50
|
+
output = res.output;
|
|
50
51
|
});
|
|
51
52
|
it('runs to completion without errors', () => {
|
|
52
53
|
expect(output).toMatchInlineSnapshot(`
|
|
53
54
|
"- Initializing...
|
|
54
55
|
? Select pull request Merge pull request #9 from backport-org/many-merge-commits
|
|
55
56
|
✔ 100% Cloning repository from github.com (one-time operation)
|
|
57
|
+
|
|
56
58
|
Backporting to 7.x:
|
|
57
59
|
- Pulling latest changes
|
|
58
60
|
✔ Pulling latest changes
|
|
@@ -88,7 +90,7 @@ describe('different-merge-strategies', () => {
|
|
|
88
90
|
`--dir=${sandboxPath}`,
|
|
89
91
|
'--pr=1',
|
|
90
92
|
'--dry-run',
|
|
91
|
-
], {
|
|
93
|
+
], { showOra: true });
|
|
92
94
|
});
|
|
93
95
|
it('backports all immediate children of the merge commit', async () => {
|
|
94
96
|
const commits = await listCommits(sandboxPath);
|