backport 6.1.5 → 6.3.0-beta-2
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 +15 -6
- package/dist/{main.d.ts → backportRun.d.ts} +3 -3
- package/dist/{main.js → backportRun.js} +21 -10
- package/dist/{entrypoint.module.private.test.d.ts → entrypoint.cli.e2e.private.test.d.ts} +0 -0
- package/dist/entrypoint.cli.e2e.private.test.js +277 -0
- package/dist/entrypoint.cli.js +3 -5
- package/dist/{options/getValidatedOptions.test.d.ts → entrypoint.cli.private.test.d.ts} +0 -0
- package/dist/{entrypoint.module.private.test.js → entrypoint.cli.private.test.js} +17 -8
- package/dist/entrypoint.module.d.ts +2 -2
- package/dist/entrypoint.module.js +4 -4
- package/dist/options/ConfigOptions.d.ts +5 -1
- package/dist/options/cliArgs.d.ts +16 -14
- package/dist/options/cliArgs.js +15 -5
- package/dist/options/cliArgs.test.js +28 -10
- package/dist/options/config/config.d.ts +10 -4
- package/dist/options/config/config.js +7 -6
- package/dist/options/config/config.test.js +11 -1
- package/dist/options/config/globalConfig.d.ts +1 -1
- package/dist/options/config/globalConfig.js +15 -9
- package/dist/options/config/globalConfig.test.js +19 -32
- package/dist/options/config/projectConfig.d.ts +3 -1
- package/dist/options/config/projectConfig.js +5 -2
- package/dist/options/config/projectConfig.test.js +41 -31
- package/dist/options/config/readConfigFile.d.ts +27 -23
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +18 -39
- package/dist/options/options.js +40 -32
- package/dist/options/options.test.js +83 -47
- package/dist/runSequentially.d.ts +0 -1
- package/dist/runSequentially.js +0 -1
- package/dist/runSequentially.test.js +39 -20
- package/dist/scripts/postinstall.js +3 -3
- package/dist/services/HandledError.d.ts +6 -4
- package/dist/services/HandledError.js +18 -3
- package/dist/services/child-process-promisified.d.ts +3 -1
- package/dist/services/env.d.ts +3 -1
- package/dist/services/env.js +4 -1
- package/dist/services/env.test.js +2 -2
- package/dist/services/git.d.ts +22 -9
- package/dist/services/git.integration.test.js +123 -24
- package/dist/services/git.js +66 -54
- package/dist/services/git.test.js +35 -20
- package/dist/services/github/commitFormatters.d.ts +0 -1
- package/dist/services/github/commitFormatters.js +1 -8
- package/dist/services/github/v3/createPullRequest.js +16 -10
- package/dist/services/github/v3/createPullRequest.test.js +248 -33
- package/dist/services/github/v3/createStatusComment.d.ts +1 -1
- package/dist/services/github/v3/createStatusComment.js +26 -15
- package/dist/services/github/v3/createStatusComment.test.js +165 -70
- package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +2 -1
- package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -7
- package/dist/services/github/v4/apiRequestV4.d.ts +21 -17
- package/dist/services/github/v4/apiRequestV4.js +38 -28
- package/dist/services/github/v4/apiRequestV4.test.js +4 -4
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -7
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -7
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +37 -19
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +17 -8
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +23 -14
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +4 -4
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +41 -19
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +1 -8
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +31 -14
- package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -4
- package/dist/services/github/v4/fetchExistingPullRequest.js +1 -2
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -9
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +6 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +41 -34
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +6 -0
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +2 -1
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +56 -0
- package/dist/{options/parseRequiredOptions.test.d.ts → services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts} +0 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +71 -0
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +11 -11
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +4 -5
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -7
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +5 -5
- package/dist/services/logger.d.ts +9 -3
- package/dist/services/logger.js +38 -35
- package/dist/services/prompt.test.js +66 -19
- package/dist/services/prompts.js +12 -10
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +1 -1
- package/dist/services/sourceCommit/getMockSourceCommit.js +6 -6
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +18 -10
- package/dist/services/sourceCommit/parseSourceCommit.js +20 -14
- package/dist/services/sourceCommit/parseSourceCommit.test.js +18 -20
- package/dist/{runWithOptions.test.d.ts → test/backport-e2e.mutation.test.d.ts} +0 -0
- package/dist/test/{integration/integration.private.test.js → backport-e2e.mutation.test.js} +143 -123
- package/dist/{scripts/generate-gql.d.ts → test/handleUnbackportedPullRequests.private.test.d.ts} +0 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +57 -0
- package/dist/test/mockConfigFiles.js +4 -20
- package/dist/test/mocks.d.ts +10 -0
- package/dist/test/mocks.js +23 -0
- package/dist/test/private/getDevAccessToken.js +5 -4
- package/dist/test/sandbox.d.ts +5 -0
- package/dist/test/sandbox.js +43 -0
- package/dist/test/setupFiles/automatic-mocks.d.ts +1 -0
- package/dist/test/setupFiles/automatic-mocks.js +27 -11
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +12 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +50 -27
- package/dist/ui/getCommits.js +8 -14
- package/dist/ui/getCommitsWithoutBackports.js +6 -6
- package/dist/ui/getCommitsWithoutBackports.test.js +91 -39
- package/dist/ui/getTargetBranches.js +1 -1
- package/dist/ui/getTargetBranches.test.js +26 -8
- package/dist/ui/maybeSetupRepo.js +25 -5
- package/dist/ui/maybeSetupRepo.test.js +144 -14
- package/dist/utils/maybe.d.ts +1 -0
- package/dist/utils/maybe.js +7 -0
- package/dist/utils/packageVersion.d.ts +1 -0
- package/dist/{types/PromiseReturnType.js → utils/packageVersion.js} +2 -0
- package/package.json +24 -20
- package/yarn.lock +160 -237
- package/dist/index.d.ts +0 -783
- package/dist/index.js +0 -8001
- package/dist/ink.d.ts +0 -1
- package/dist/ink.js +0 -49
- package/dist/options/config/getOptionsFromGit.d.ts +0 -4
- package/dist/options/config/getOptionsFromGit.js +0 -8
- package/dist/options/getValidatedOptions.d.ts +0 -49
- package/dist/options/getValidatedOptions.js +0 -45
- package/dist/options/getValidatedOptions.test.js +0 -97
- package/dist/options/parseRequiredOptions.d.ts +0 -71
- package/dist/options/parseRequiredOptions.js +0 -68
- package/dist/options/parseRequiredOptions.test.js +0 -122
- package/dist/runWithOptions.d.ts +0 -9
- package/dist/runWithOptions.js +0 -43
- package/dist/runWithOptions.test.js +0 -304
- package/dist/scripts/generate-gql.js +0 -15
- package/dist/services/fs-promisified.d.ts +0 -6
- package/dist/services/fs-promisified.js +0 -12
- package/dist/services/getExpectedTarget.d.ts +0 -9
- package/dist/services/getExpectedTarget.js +0 -77
- package/dist/services/getExpectedTargetPullRequests.d.ts +0 -9
- package/dist/services/getExpectedTargetPullRequests.js +0 -77
- package/dist/services/github/v4/fetchCommitByPullNumber.d.ts +0 -5
- package/dist/services/github/v4/fetchCommitByPullNumber.js +0 -86
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.js +0 -57
- package/dist/services/github/v4/fetchCommitBySha.d.ts +0 -5
- package/dist/services/github/v4/fetchCommitBySha.js +0 -95
- package/dist/services/github/v4/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitBySha.private.test.js +0 -50
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.d.ts +0 -28
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.js +0 -52
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.d.ts +0 -3
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.js +0 -55
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.js +0 -252
- package/dist/services/github/v4/fetchCommitsByAuthor.d.ts +0 -28
- package/dist/services/github/v4/fetchCommitsByAuthor.js +0 -161
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +0 -115
- package/dist/services/github/v4/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitsByAuthor.test.js +0 -272
- package/dist/services/github/v4/fetchDefaultBranch.d.ts +0 -9
- package/dist/services/github/v4/fetchDefaultBranch.js +0 -24
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -4
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -52
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.d.ts +0 -4
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.js +0 -72
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.js +0 -34
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.d.ts +0 -40
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.js +0 -72
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -17
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -69
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
- package/dist/services/github/v4/fetchMergedPullRequests.d.ts +0 -37
- package/dist/services/github/v4/fetchMergedPullRequests.js +0 -37
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.js +0 -59
- package/dist/services/github/v4/fetchMergedPullRequests.test.d.ts +0 -1
- package/dist/services/github/v4/fetchMergedPullRequests.test.js +0 -22
- package/dist/services/github/v4/fetchProjectConfig.d.ts +0 -8
- package/dist/services/github/v4/fetchProjectConfig.js +0 -56
- package/dist/services/github/v4/fetchProjectConfig.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchProjectConfig.private.test.js +0 -52
- package/dist/services/github/v4/fetchProjectConfig.test.d.ts +0 -1
- package/dist/services/github/v4/fetchProjectConfig.test.js +0 -37
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.d.ts +0 -9
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +0 -92
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +0 -66
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.d.ts +0 -1
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.js +0 -242
- package/dist/services/github/v4/getExistingTargetPullRequests.d.ts +0 -7
- package/dist/services/github/v4/getExistingTargetPullRequests.js +0 -45
- package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +0 -63
- package/dist/services/github/v4/getOptionsFromGithub/index.js +0 -139
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.d.ts +0 -1
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +0 -147
- package/dist/services/github/v4/getTargetBranchesFromLabels.d.ts +0 -5
- package/dist/services/github/v4/getTargetBranchesFromLabels.js +0 -20
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.js +0 -201
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +0 -843
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +0 -73
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.d.ts +0 -12
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.js +0 -44
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.d.ts +0 -5
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.js +0 -20
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.js +0 -201
- package/dist/services/sourceCommit/sourceCommit.d.ts +0 -78
- package/dist/services/sourceCommit/sourceCommit.js +0 -86
- package/dist/services/sourceCommit/sourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit/sourceCommit.test.js +0 -287
- package/dist/services/sourceCommit.d.ts +0 -78
- package/dist/services/sourceCommit.js +0 -86
- package/dist/services/sourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit.test.js +0 -280
- package/dist/test/inquirer.private.test.d.ts +0 -1
- package/dist/test/inquirer.private.test.js +0 -168
- package/dist/test/integration/createSpies.d.ts +0 -17
- package/dist/test/integration/createSpies.js +0 -85
- package/dist/test/integration/envConstants.d.ts +0 -5
- package/dist/test/integration/envConstants.js +0 -9
- package/dist/test/integration/helpers.d.ts +0 -7
- package/dist/test/integration/helpers.js +0 -31
- package/dist/test/integration/integration.private.test.d.ts +0 -1
- package/dist/test/integration/integration.test.d.ts +0 -1
- package/dist/test/integration/integration.test.js +0 -214
- package/dist/todo-delete.d.ts +0 -1
- package/dist/todo-delete.js +0 -17
- package/dist/types/Commit.d.ts +0 -85
- package/dist/types/Commit.js +0 -139
- package/dist/types/PromiseReturnType.d.ts +0 -1
- package/dist/types/commitNode.d.ts +0 -89
- package/dist/types/commitNode.js +0 -139
- package/dist/types/commitNode.test.d.ts +0 -1
- package/dist/types/commitNode.test.js +0 -255
- package/dist/types/commitWithAssociatedPullRequests.d.ts +0 -86
- package/dist/types/commitWithAssociatedPullRequests.js +0 -145
- package/dist/ui/cherrypickAndCreatePullRequest.test.d.ts +0 -1
- package/dist/ui/cherrypickAndCreatePullRequest.test.js +0 -617
- package/dist/ui/getTargetBranchesFromLabels.d.ts +0 -6
- package/dist/ui/getTargetBranchesFromLabels.js +0 -40
- package/dist/ui/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/ui/getTargetBranchesFromLabels.test.js +0 -288
package/dist/services/prompts.js
CHANGED
|
@@ -75,19 +75,21 @@ function getChoicesForCommitPrompt(commits, showDetails) {
|
|
|
75
75
|
const position = chalk_1.default.gray(`${i + 1}.${leadingWhitespace}`);
|
|
76
76
|
let name;
|
|
77
77
|
if (showDetails) {
|
|
78
|
-
const message = (0, commitFormatters_1.stripPullNumber)(c.
|
|
79
|
-
const prLink = c.
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
const message = (0, commitFormatters_1.stripPullNumber)(c.sourceCommit.message);
|
|
79
|
+
const prLink = c.sourcePullRequest
|
|
80
|
+
? ` ` + getPrLink(c.sourcePullRequest.number, c.sourcePullRequest.url)
|
|
81
|
+
: '';
|
|
82
|
+
const pullStatus = getDetailedPullStatus(c);
|
|
83
|
+
name = `${position}${message}${prLink}${pullStatus}`;
|
|
82
84
|
}
|
|
83
85
|
else {
|
|
84
|
-
const message = (0, commitFormatters_1.getFirstLine)(c.
|
|
85
|
-
const
|
|
86
|
-
name = `${position}${message} ${
|
|
86
|
+
const message = (0, commitFormatters_1.getFirstLine)(c.sourceCommit.message);
|
|
87
|
+
const pullStatus = getSimplePullStatus(c);
|
|
88
|
+
name = `${position}${message} ${pullStatus}`;
|
|
87
89
|
}
|
|
88
|
-
const short = c.
|
|
89
|
-
? `#${c.
|
|
90
|
-
: (0, commitFormatters_1.getShortSha)(c.sha);
|
|
90
|
+
const short = c.sourcePullRequest
|
|
91
|
+
? `#${c.sourcePullRequest.number} (${(0, commitFormatters_1.getShortSha)(c.sourcePullRequest.mergeCommit.sha)})`
|
|
92
|
+
: (0, commitFormatters_1.getShortSha)(c.sourceCommit.sha);
|
|
91
93
|
return { name, short, value: c };
|
|
92
94
|
});
|
|
93
95
|
}
|
|
@@ -54,7 +54,7 @@ function getExistingTargetPullRequests(sourceCommit, sourcePullRequest) {
|
|
|
54
54
|
state: targetPullRequest.state,
|
|
55
55
|
mergeCommit: targetPullRequest.targetMergeCommit
|
|
56
56
|
? {
|
|
57
|
-
sha: targetPullRequest.targetMergeCommit.
|
|
57
|
+
sha: targetPullRequest.targetMergeCommit.sha,
|
|
58
58
|
message: targetPullRequest.targetMergeCommit.message,
|
|
59
59
|
}
|
|
60
60
|
: undefined,
|
|
@@ -10,7 +10,7 @@ function getMockSourceCommit({ sourceCommit, sourcePullRequest, timelineItems =
|
|
|
10
10
|
owner: { login: 'elastic' },
|
|
11
11
|
},
|
|
12
12
|
committedDate: sourceCommit.commitedDate ?? '2021-12-22T00:00:00Z',
|
|
13
|
-
|
|
13
|
+
sha: sourceCommit.sha ?? defaultSourceCommitSha,
|
|
14
14
|
message: sourceCommit.message,
|
|
15
15
|
};
|
|
16
16
|
if (!sourcePullRequest) {
|
|
@@ -27,14 +27,14 @@ function getMockSourceCommit({ sourceCommit, sourcePullRequest, timelineItems =
|
|
|
27
27
|
owner: { login: 'elastic' },
|
|
28
28
|
},
|
|
29
29
|
committedDate: sourceCommit.commitedDate ?? '2021-12-22T00:00:00Z',
|
|
30
|
-
|
|
30
|
+
sha: sourceCommit.sha ?? defaultSourceCommitSha,
|
|
31
31
|
message: sourceCommit.message,
|
|
32
32
|
associatedPullRequests: {
|
|
33
33
|
edges: [
|
|
34
34
|
{
|
|
35
35
|
node: {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
mergeCommit: {
|
|
37
|
+
sha: sourceCommit.sha ?? defaultSourceCommitSha,
|
|
38
38
|
message: sourceCommit.message,
|
|
39
39
|
},
|
|
40
40
|
url: `https://github.com/elastic/kibana/pull/${sourcePullRequest.number}`,
|
|
@@ -60,7 +60,7 @@ function getMockSourceCommit({ sourceCommit, sourcePullRequest, timelineItems =
|
|
|
60
60
|
targetMergeCommit: timelineItem.state === 'MERGED'
|
|
61
61
|
? {
|
|
62
62
|
message: timelineItem.commitMessages[0],
|
|
63
|
-
|
|
63
|
+
sha: 'target-merge-commit-sha',
|
|
64
64
|
}
|
|
65
65
|
: null,
|
|
66
66
|
repository: {
|
|
@@ -73,7 +73,7 @@ function getMockSourceCommit({ sourceCommit, sourcePullRequest, timelineItems =
|
|
|
73
73
|
edges: timelineItem.commitMessages.map((message) => ({
|
|
74
74
|
node: {
|
|
75
75
|
targetCommit: {
|
|
76
|
-
|
|
76
|
+
sha: 'abc',
|
|
77
77
|
message: message,
|
|
78
78
|
},
|
|
79
79
|
},
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../../options/options';
|
|
2
2
|
import { ExpectedTargetPullRequest } from './getExpectedTargetPullRequests';
|
|
3
3
|
export interface Commit {
|
|
4
|
-
|
|
4
|
+
sourceCommit: {
|
|
5
|
+
committedDate: string;
|
|
6
|
+
message: string;
|
|
7
|
+
sha: string;
|
|
8
|
+
};
|
|
9
|
+
sourcePullRequest?: {
|
|
10
|
+
number: number;
|
|
11
|
+
url: string;
|
|
12
|
+
mergeCommit: {
|
|
13
|
+
message: string;
|
|
14
|
+
sha: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
5
17
|
sourceBranch: string;
|
|
6
|
-
sha: string;
|
|
7
|
-
originalMessage: string;
|
|
8
|
-
pullNumber?: number;
|
|
9
|
-
pullUrl?: string;
|
|
10
18
|
expectedTargetPullRequests: ExpectedTargetPullRequest[];
|
|
11
19
|
}
|
|
12
20
|
export interface SourcePullRequestNode {
|
|
@@ -18,8 +26,8 @@ export interface SourcePullRequestNode {
|
|
|
18
26
|
name: string;
|
|
19
27
|
}[];
|
|
20
28
|
};
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
mergeCommit: {
|
|
30
|
+
sha: string;
|
|
23
31
|
message: string;
|
|
24
32
|
};
|
|
25
33
|
timelineItems: {
|
|
@@ -37,7 +45,7 @@ export interface TimelinePullRequestEdge {
|
|
|
37
45
|
baseRefName: string;
|
|
38
46
|
number: number;
|
|
39
47
|
targetMergeCommit: {
|
|
40
|
-
|
|
48
|
+
sha: string;
|
|
41
49
|
message: string;
|
|
42
50
|
} | null;
|
|
43
51
|
repository: {
|
|
@@ -51,7 +59,7 @@ export interface TimelinePullRequestEdge {
|
|
|
51
59
|
node: {
|
|
52
60
|
targetCommit: {
|
|
53
61
|
message: string;
|
|
54
|
-
|
|
62
|
+
sha: string;
|
|
55
63
|
};
|
|
56
64
|
};
|
|
57
65
|
}>;
|
|
@@ -73,7 +81,7 @@ export declare type SourceCommitWithTargetPullRequest = {
|
|
|
73
81
|
login: string;
|
|
74
82
|
};
|
|
75
83
|
};
|
|
76
|
-
|
|
84
|
+
sha: string;
|
|
77
85
|
message: string;
|
|
78
86
|
committedDate: string;
|
|
79
87
|
associatedPullRequests: {
|
|
@@ -2,24 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sourceCommitWithTargetPullRequestFragment = exports.parseSourceCommit = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
|
-
const commitFormatters_1 = require("../github/commitFormatters");
|
|
6
5
|
const getExpectedTargetPullRequests_1 = require("./getExpectedTargetPullRequests");
|
|
7
6
|
function parseSourceCommit({ sourceCommit, options, }) {
|
|
8
7
|
const sourcePullRequest = sourceCommit.associatedPullRequests.edges?.[0]?.node;
|
|
9
8
|
// use info from associated pull request if available. Fall back to commit info
|
|
10
|
-
const commitMessage = sourcePullRequest?.sourceMergeCommit.message ?? sourceCommit.message;
|
|
11
|
-
const commitSha = sourcePullRequest?.sourceMergeCommit.oid ?? sourceCommit.oid;
|
|
12
|
-
const pullNumber = sourcePullRequest?.number ?? (0, commitFormatters_1.extractPullNumber)(commitMessage);
|
|
13
9
|
const sourceBranch = sourcePullRequest?.baseRefName ?? options.sourceBranch;
|
|
14
10
|
const branchLabelMapping = getBranchLabelMappingForCommit(sourceCommit, options.branchLabelMapping, options.historicalBranchLabelMappings);
|
|
15
11
|
const expectedTargetPullRequests = (0, getExpectedTargetPullRequests_1.getExpectedTargetPullRequests)(sourceCommit, branchLabelMapping);
|
|
16
12
|
return {
|
|
17
|
-
|
|
13
|
+
sourceCommit: {
|
|
14
|
+
committedDate: sourceCommit.committedDate,
|
|
15
|
+
message: sourceCommit.message,
|
|
16
|
+
sha: sourceCommit.sha,
|
|
17
|
+
},
|
|
18
|
+
sourcePullRequest: sourcePullRequest
|
|
19
|
+
? {
|
|
20
|
+
number: sourcePullRequest.number,
|
|
21
|
+
url: sourcePullRequest.url,
|
|
22
|
+
mergeCommit: {
|
|
23
|
+
message: sourcePullRequest.mergeCommit.message,
|
|
24
|
+
sha: sourcePullRequest.mergeCommit.sha,
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
: undefined,
|
|
18
28
|
sourceBranch,
|
|
19
|
-
sha: commitSha,
|
|
20
|
-
originalMessage: commitMessage,
|
|
21
|
-
pullNumber,
|
|
22
|
-
pullUrl: sourcePullRequest?.url,
|
|
23
29
|
expectedTargetPullRequests,
|
|
24
30
|
};
|
|
25
31
|
}
|
|
@@ -34,7 +40,7 @@ exports.sourceCommitWithTargetPullRequestFragment = {
|
|
|
34
40
|
login
|
|
35
41
|
}
|
|
36
42
|
}
|
|
37
|
-
oid
|
|
43
|
+
sha: oid
|
|
38
44
|
message
|
|
39
45
|
committedDate
|
|
40
46
|
|
|
@@ -52,8 +58,8 @@ exports.sourceCommitWithTargetPullRequestFragment = {
|
|
|
52
58
|
baseRefName
|
|
53
59
|
|
|
54
60
|
# source merge commit (the commit that actually went into the source branch)
|
|
55
|
-
|
|
56
|
-
oid
|
|
61
|
+
mergeCommit {
|
|
62
|
+
sha: oid
|
|
57
63
|
message
|
|
58
64
|
}
|
|
59
65
|
|
|
@@ -69,7 +75,7 @@ exports.sourceCommitWithTargetPullRequestFragment = {
|
|
|
69
75
|
... on PullRequest {
|
|
70
76
|
# target merge commit: the backport commit that was merged into the target branch
|
|
71
77
|
targetMergeCommit: mergeCommit {
|
|
72
|
-
oid
|
|
78
|
+
sha: oid
|
|
73
79
|
message
|
|
74
80
|
}
|
|
75
81
|
repository {
|
|
@@ -88,7 +94,7 @@ exports.sourceCommitWithTargetPullRequestFragment = {
|
|
|
88
94
|
node {
|
|
89
95
|
targetCommit: commit {
|
|
90
96
|
message
|
|
91
|
-
oid
|
|
97
|
+
sha: oid
|
|
92
98
|
}
|
|
93
99
|
}
|
|
94
100
|
}
|
|
@@ -13,18 +13,7 @@ describe('parseSourceCommit', () => {
|
|
|
13
13
|
sourceCommit: mockSourceCommit,
|
|
14
14
|
options: {},
|
|
15
15
|
});
|
|
16
|
-
expect(commit.
|
|
17
|
-
});
|
|
18
|
-
it('extracts `pullNumber` from commit message if it doesnt have any associated PRs', () => {
|
|
19
|
-
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
20
|
-
sourceCommit: { message: 'My commit message (#66)' },
|
|
21
|
-
sourcePullRequest: null,
|
|
22
|
-
});
|
|
23
|
-
const commit = (0, parseSourceCommit_1.parseSourceCommit)({
|
|
24
|
-
sourceCommit: mockSourceCommit,
|
|
25
|
-
options: {},
|
|
26
|
-
});
|
|
27
|
-
expect(commit.pullNumber).toBe(66);
|
|
16
|
+
expect(commit.sourcePullRequest?.number).toBe(55);
|
|
28
17
|
});
|
|
29
18
|
});
|
|
30
19
|
describe('sourceBranch', () => {
|
|
@@ -203,8 +192,21 @@ describe('parseSourceCommit', () => {
|
|
|
203
192
|
},
|
|
204
193
|
},
|
|
205
194
|
});
|
|
206
|
-
|
|
207
|
-
|
|
195
|
+
const expectedCommit = {
|
|
196
|
+
sourceCommit: {
|
|
197
|
+
committedDate: '2021-12-22T00:00:00Z',
|
|
198
|
+
message: 'My commit message (#1234)',
|
|
199
|
+
sha: 'my-sha',
|
|
200
|
+
},
|
|
201
|
+
sourcePullRequest: {
|
|
202
|
+
number: 1234,
|
|
203
|
+
url: 'https://github.com/elastic/kibana/pull/1234',
|
|
204
|
+
mergeCommit: {
|
|
205
|
+
message: 'My commit message (#1234)',
|
|
206
|
+
sha: 'my-sha',
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
sourceBranch: 'source-branch-from-associated-pull-request',
|
|
208
210
|
expectedTargetPullRequests: [
|
|
209
211
|
{
|
|
210
212
|
branch: '6.x',
|
|
@@ -227,11 +229,7 @@ describe('parseSourceCommit', () => {
|
|
|
227
229
|
state: 'MISSING',
|
|
228
230
|
},
|
|
229
231
|
],
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
pullUrl: 'https://github.com/elastic/kibana/pull/1234',
|
|
233
|
-
sha: 'my-sha',
|
|
234
|
-
sourceBranch: 'source-branch-from-associated-pull-request',
|
|
235
|
-
});
|
|
232
|
+
};
|
|
233
|
+
expect(commit).toEqual(expectedCommit);
|
|
236
234
|
});
|
|
237
235
|
});
|
|
File without changes
|
|
@@ -5,32 +5,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
/* eslint-disable jest/no-commented-out-tests */
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
|
-
const path_1 = require("path");
|
|
9
8
|
const rest_1 = require("@octokit/rest");
|
|
10
|
-
const del = require("del");
|
|
11
9
|
const nock_1 = __importDefault(require("nock"));
|
|
12
|
-
const options_1 = require("
|
|
13
|
-
const runSequentially_1 = require("
|
|
14
|
-
const getCommits_1 = require("
|
|
15
|
-
const mockConfigFiles_1 = require("
|
|
16
|
-
const nockHelpers_1 = require("
|
|
17
|
-
const getDevAccessToken_1 = require("
|
|
18
|
-
|
|
19
|
-
jest.unmock('del');
|
|
10
|
+
const options_1 = require("../options/options");
|
|
11
|
+
const runSequentially_1 = require("../runSequentially");
|
|
12
|
+
const getCommits_1 = require("../ui/getCommits");
|
|
13
|
+
const mockConfigFiles_1 = require("./mockConfigFiles");
|
|
14
|
+
const nockHelpers_1 = require("./nockHelpers");
|
|
15
|
+
const getDevAccessToken_1 = require("./private/getDevAccessToken");
|
|
16
|
+
const sandbox_1 = require("./sandbox");
|
|
20
17
|
jest.setTimeout(10000);
|
|
21
|
-
const
|
|
22
|
-
const HOMEDIR_PATH = (0, path_1.resolve)('./src/test/integration/mock-environment/homedir');
|
|
18
|
+
const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
23
19
|
const REPO_OWNER = 'backport-org';
|
|
24
20
|
const REPO_NAME = 'integration-test';
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
21
|
+
const BRANCH_WITH_ONE_COMMIT = 'backport/7.x/commit-5bf29b7d';
|
|
22
|
+
const BRANCH_WITH_TWO_COMMITS = 'backport/7.x/commit-5bf29b7d_commit-59d6ff1c';
|
|
23
|
+
const AUTHOR = 'sqren';
|
|
24
|
+
describe('backport e2e', () => {
|
|
25
|
+
let accessToken;
|
|
28
26
|
afterAll(() => {
|
|
29
27
|
nock_1.default.cleanAll();
|
|
30
28
|
});
|
|
31
|
-
beforeAll(() => {
|
|
29
|
+
beforeAll(async () => {
|
|
32
30
|
// set alternative homedir
|
|
33
|
-
jest.spyOn(os_1.default, 'homedir').mockReturnValue(
|
|
31
|
+
jest.spyOn(os_1.default, 'homedir').mockReturnValue(`${sandboxPath}/homedir`);
|
|
32
|
+
accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
34
33
|
(0, mockConfigFiles_1.mockConfigFiles)({
|
|
35
34
|
globalConfig: {},
|
|
36
35
|
projectConfig: {},
|
|
@@ -38,23 +37,21 @@ describe('integration', () => {
|
|
|
38
37
|
});
|
|
39
38
|
describe('when a single commit is backported', () => {
|
|
40
39
|
let res;
|
|
41
|
-
let accessToken;
|
|
42
40
|
let createPullRequestsMockCalls;
|
|
43
41
|
beforeAll(async () => {
|
|
44
|
-
accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
45
42
|
await resetState(accessToken);
|
|
46
43
|
createPullRequestsMockCalls = mockCreatePullRequest({
|
|
47
44
|
number: 1337,
|
|
48
45
|
html_url: 'myHtmlUrl',
|
|
49
46
|
});
|
|
50
47
|
const options = await (0, options_1.getOptions)([], {
|
|
51
|
-
githubApiBaseUrlV3: 'https://api.foo.com',
|
|
52
|
-
ci: true,
|
|
53
|
-
sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
54
|
-
author: AUHTOR,
|
|
55
48
|
accessToken,
|
|
56
|
-
|
|
49
|
+
author: AUTHOR,
|
|
50
|
+
ci: true,
|
|
51
|
+
githubApiBaseUrlV3: 'https://api.foo.com',
|
|
57
52
|
repoName: 'integration-test',
|
|
53
|
+
repoOwner: 'backport-org',
|
|
54
|
+
sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
58
55
|
});
|
|
59
56
|
const commits = await (0, getCommits_1.getCommits)(options);
|
|
60
57
|
const targetBranches = ['7.x'];
|
|
@@ -78,12 +75,13 @@ describe('integration', () => {
|
|
|
78
75
|
"base": "7.x",
|
|
79
76
|
"body": "# Backport
|
|
80
77
|
|
|
81
|
-
This
|
|
78
|
+
This will backport the following commits from \`master\` to \`7.x\`:
|
|
82
79
|
- Add ❤️ emoji (5bf29b7d)
|
|
83
80
|
|
|
81
|
+
<!--- Backport version: 1.2.3 -->
|
|
82
|
+
|
|
84
83
|
### Questions ?
|
|
85
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
86
|
-
",
|
|
84
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
87
85
|
"head": "sqren:backport/7.x/commit-5bf29b7d",
|
|
88
86
|
"title": "[7.x] Add ❤️ emoji",
|
|
89
87
|
},
|
|
@@ -101,107 +99,117 @@ describe('integration', () => {
|
|
|
101
99
|
it('should create branch in the fork (sqren/integration-test)', async () => {
|
|
102
100
|
const branches = await getBranches({
|
|
103
101
|
accessToken,
|
|
104
|
-
repoOwner:
|
|
102
|
+
repoOwner: AUTHOR,
|
|
105
103
|
repoName: REPO_NAME,
|
|
106
104
|
});
|
|
107
105
|
expect(branches.map((b) => b.name)).toEqual([
|
|
108
106
|
'7.x',
|
|
109
|
-
|
|
107
|
+
BRANCH_WITH_ONE_COMMIT,
|
|
110
108
|
'master',
|
|
111
109
|
]);
|
|
112
110
|
});
|
|
113
|
-
|
|
111
|
+
});
|
|
112
|
+
describe('when two commits are backported', () => {
|
|
113
|
+
let createPullRequestsMockCalls;
|
|
114
|
+
let res;
|
|
115
|
+
beforeAll(async () => {
|
|
116
|
+
await resetState(accessToken);
|
|
117
|
+
createPullRequestsMockCalls = mockCreatePullRequest({
|
|
118
|
+
number: 1337,
|
|
119
|
+
html_url: 'myHtmlUrl',
|
|
120
|
+
});
|
|
121
|
+
const options = await (0, options_1.getOptions)([], {
|
|
122
|
+
accessToken,
|
|
123
|
+
author: AUTHOR,
|
|
124
|
+
ci: true,
|
|
125
|
+
githubApiBaseUrlV3: 'https://api.foo.com',
|
|
126
|
+
repoName: 'integration-test',
|
|
127
|
+
repoOwner: 'backport-org',
|
|
128
|
+
});
|
|
129
|
+
const commits = [
|
|
130
|
+
...(await (0, getCommits_1.getCommits)({
|
|
131
|
+
...options,
|
|
132
|
+
sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
133
|
+
})),
|
|
134
|
+
...(await (0, getCommits_1.getCommits)({
|
|
135
|
+
...options,
|
|
136
|
+
sha: '59d6ff1ca90a4ce210c0a4f0e159214875c19d60',
|
|
137
|
+
})),
|
|
138
|
+
];
|
|
139
|
+
const targetBranches = ['7.x'];
|
|
140
|
+
res = await (0, runSequentially_1.runSequentially)({ options, commits, targetBranches });
|
|
141
|
+
});
|
|
142
|
+
it('contains both commits in the pull request body', () => {
|
|
143
|
+
expect(createPullRequestsMockCalls).toMatchInlineSnapshot(`
|
|
144
|
+
Array [
|
|
145
|
+
Object {
|
|
146
|
+
"base": "7.x",
|
|
147
|
+
"body": "# Backport
|
|
148
|
+
|
|
149
|
+
This will backport the following commits from \`master\` to \`7.x\`:
|
|
150
|
+
- Add ❤️ emoji (5bf29b7d)
|
|
151
|
+
- Add family emoji (#2) (59d6ff1c)
|
|
152
|
+
|
|
153
|
+
<!--- Backport version: 1.2.3 -->
|
|
154
|
+
|
|
155
|
+
### Questions ?
|
|
156
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
157
|
+
"head": "sqren:backport/7.x/commit-5bf29b7d_commit-59d6ff1c",
|
|
158
|
+
"title": "[7.x] Add ❤️ emoji | Add family emoji (#2)",
|
|
159
|
+
},
|
|
160
|
+
]
|
|
161
|
+
`);
|
|
162
|
+
});
|
|
163
|
+
it('returns the pull request response', () => {
|
|
164
|
+
expect(res).toEqual([
|
|
165
|
+
{
|
|
166
|
+
didUpdate: false,
|
|
167
|
+
pullRequestNumber: 1337,
|
|
168
|
+
status: 'success',
|
|
169
|
+
pullRequestUrl: 'myHtmlUrl',
|
|
170
|
+
targetBranch: '7.x',
|
|
171
|
+
},
|
|
172
|
+
]);
|
|
173
|
+
});
|
|
174
|
+
it('should not create new branches in origin (backport-org/integration-test)', async () => {
|
|
114
175
|
const branches = await getBranches({
|
|
115
176
|
accessToken,
|
|
116
|
-
repoOwner:
|
|
177
|
+
repoOwner: REPO_OWNER,
|
|
178
|
+
repoName: REPO_NAME,
|
|
179
|
+
});
|
|
180
|
+
expect(branches.map((b) => b.name)).toEqual(['7.x', 'master']);
|
|
181
|
+
});
|
|
182
|
+
it('should create branch in the fork (sqren/integration-test)', async () => {
|
|
183
|
+
const branches = await getBranches({
|
|
184
|
+
accessToken,
|
|
185
|
+
repoOwner: AUTHOR,
|
|
117
186
|
repoName: REPO_NAME,
|
|
118
187
|
});
|
|
119
|
-
|
|
120
|
-
|
|
188
|
+
expect(branches.map((b) => b.name)).toEqual([
|
|
189
|
+
'7.x',
|
|
190
|
+
BRANCH_WITH_TWO_COMMITS,
|
|
191
|
+
'master',
|
|
192
|
+
]);
|
|
121
193
|
});
|
|
122
194
|
});
|
|
123
|
-
// describe.skip('when two commits are backported', () => {
|
|
124
|
-
// let createPullRequestsMockCalls: unknown[];
|
|
125
|
-
// let res: Awaited<ReturnType<typeof runSequentially>>;
|
|
126
|
-
// let accessToken: string;
|
|
127
|
-
// beforeAll(async () => {
|
|
128
|
-
// accessToken = await getDevAccessToken();
|
|
129
|
-
// await resetState(accessToken);
|
|
130
|
-
// createPullRequestsMockCalls = mockCreatePullRequest({
|
|
131
|
-
// number: 1337,
|
|
132
|
-
// html_url: 'myHtmlUrl',
|
|
133
|
-
// });
|
|
134
|
-
// const options = {
|
|
135
|
-
// githubApiBaseUrlV3: 'https://api.foo.com',
|
|
136
|
-
// ci: true,
|
|
137
|
-
// sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
138
|
-
// author: AUHTOR,
|
|
139
|
-
// accessToken,
|
|
140
|
-
// repoOwner: 'backport-org',
|
|
141
|
-
// reponame: 'integration-test',
|
|
142
|
-
// } as ValidConfigOptions;
|
|
143
|
-
// const commits = await getCommits(options);
|
|
144
|
-
// const targetBranches: string[] = ['7.x'];
|
|
145
|
-
// res = await runSequentially({ options, commits, targetBranches });
|
|
146
|
-
// });
|
|
147
|
-
// it('sends the correct http body when creating pull request', () => {
|
|
148
|
-
// expect(createPullRequestsMockCalls).toMatchInlineSnapshot();
|
|
149
|
-
// });
|
|
150
|
-
// it('returns pull request', () => {
|
|
151
|
-
// expect(res).toEqual([
|
|
152
|
-
// { pullRequestUrl: 'myHtmlUrl', success: true, targetBranch: '6.0' },
|
|
153
|
-
// ]);
|
|
154
|
-
// });
|
|
155
|
-
// it('should not create new branches in origin (backport-org/integration-test)', async () => {
|
|
156
|
-
// const branches = await getBranches({
|
|
157
|
-
// accessToken,
|
|
158
|
-
// repoOwner: REPO_OWNER,
|
|
159
|
-
// repoName: REPO_NAME,
|
|
160
|
-
// });
|
|
161
|
-
// expect(branches.map((b) => b.name)).toEqual(['7.x', '* master']);
|
|
162
|
-
// });
|
|
163
|
-
// it('should create branch in the fork (sqren/integration-test)', async () => {
|
|
164
|
-
// const branches = await getBranches({
|
|
165
|
-
// accessToken,
|
|
166
|
-
// repoOwner: AUHTOR,
|
|
167
|
-
// repoName: REPO_NAME,
|
|
168
|
-
// });
|
|
169
|
-
// expect(branches.map((b) => b.name)).toEqual([
|
|
170
|
-
// '7.x',
|
|
171
|
-
// 'backport/6.0/pr-85_commit-2e63475c',
|
|
172
|
-
// 'master',
|
|
173
|
-
// ]);
|
|
174
|
-
// });
|
|
175
|
-
// it('should have cherry picked the correct commit', async () => {
|
|
176
|
-
// const branches = await getBranches({
|
|
177
|
-
// accessToken,
|
|
178
|
-
// repoOwner: AUHTOR,
|
|
179
|
-
// repoName: REPO_NAME,
|
|
180
|
-
// });
|
|
181
|
-
// const sha = branches.find((branch) => branch.name === '7.x')?.commit.sha;
|
|
182
|
-
// expect(sha).toEqual('foo');
|
|
183
|
-
// });
|
|
184
|
-
// });
|
|
185
195
|
describe('when disabling fork mode', () => {
|
|
186
196
|
let res;
|
|
187
|
-
let accessToken;
|
|
188
197
|
let createPullRequestsMockCalls;
|
|
189
198
|
beforeAll(async () => {
|
|
190
|
-
accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
191
199
|
await resetState(accessToken);
|
|
192
200
|
createPullRequestsMockCalls = mockCreatePullRequest({
|
|
193
201
|
number: 1337,
|
|
194
202
|
html_url: 'myHtmlUrl',
|
|
195
203
|
});
|
|
196
204
|
const options = await (0, options_1.getOptions)([], {
|
|
197
|
-
author: AUHTOR,
|
|
198
|
-
githubApiBaseUrlV3: 'https://api.foo.com',
|
|
199
|
-
ci: true,
|
|
200
|
-
sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
201
205
|
accessToken,
|
|
202
|
-
|
|
203
|
-
|
|
206
|
+
author: AUTHOR,
|
|
207
|
+
ci: true,
|
|
204
208
|
fork: false,
|
|
209
|
+
githubApiBaseUrlV3: 'https://api.foo.com',
|
|
210
|
+
repoName: 'integration-test',
|
|
211
|
+
repoOwner: 'backport-org',
|
|
212
|
+
sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
205
213
|
});
|
|
206
214
|
const commits = await (0, getCommits_1.getCommits)(options);
|
|
207
215
|
const targetBranches = ['7.x'];
|
|
@@ -214,12 +222,13 @@ describe('integration', () => {
|
|
|
214
222
|
"base": "7.x",
|
|
215
223
|
"body": "# Backport
|
|
216
224
|
|
|
217
|
-
This
|
|
225
|
+
This will backport the following commits from \`master\` to \`7.x\`:
|
|
218
226
|
- Add ❤️ emoji (5bf29b7d)
|
|
219
227
|
|
|
228
|
+
<!--- Backport version: 1.2.3 -->
|
|
229
|
+
|
|
220
230
|
### Questions ?
|
|
221
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
222
|
-
",
|
|
231
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
223
232
|
"head": "backport-org:backport/7.x/commit-5bf29b7d",
|
|
224
233
|
"title": "[7.x] Add ❤️ emoji",
|
|
225
234
|
},
|
|
@@ -245,27 +254,18 @@ describe('integration', () => {
|
|
|
245
254
|
});
|
|
246
255
|
expect(branches.map((b) => b.name)).toEqual([
|
|
247
256
|
'7.x',
|
|
248
|
-
|
|
257
|
+
BRANCH_WITH_ONE_COMMIT,
|
|
249
258
|
'master',
|
|
250
259
|
]);
|
|
251
260
|
});
|
|
252
261
|
it('should NOT create branch in the fork (sqren/integration-test)', async () => {
|
|
253
262
|
const branches = await getBranches({
|
|
254
263
|
accessToken,
|
|
255
|
-
repoOwner:
|
|
264
|
+
repoOwner: AUTHOR,
|
|
256
265
|
repoName: REPO_NAME,
|
|
257
266
|
});
|
|
258
267
|
expect(branches.map((b) => b.name)).toEqual(['7.x', 'master']);
|
|
259
268
|
});
|
|
260
|
-
it('should cherry pick the correct commit', async () => {
|
|
261
|
-
const branches = await getBranches({
|
|
262
|
-
accessToken,
|
|
263
|
-
repoOwner: REPO_OWNER,
|
|
264
|
-
repoName: REPO_NAME,
|
|
265
|
-
});
|
|
266
|
-
const sha = branches.find((branch) => branch.name === '7.x')?.commit.sha;
|
|
267
|
-
expect(sha).toEqual('b68e4fcaaf4427fe1e902c718b3bb3f07b560fb5');
|
|
268
|
-
});
|
|
269
269
|
});
|
|
270
270
|
});
|
|
271
271
|
function mockCreatePullRequest(response) {
|
|
@@ -311,17 +311,37 @@ async function deleteBranch({ accessToken, repoOwner, repoName, branchName, }) {
|
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
async function resetState(accessToken) {
|
|
314
|
-
await
|
|
314
|
+
const ownerBranches = await getBranches({
|
|
315
315
|
accessToken,
|
|
316
316
|
repoOwner: REPO_OWNER,
|
|
317
317
|
repoName: REPO_NAME,
|
|
318
|
-
branchName: BRANCH_NAME,
|
|
319
318
|
});
|
|
320
|
-
|
|
319
|
+
// delete all branches except master and 7.x
|
|
320
|
+
await Promise.all(ownerBranches
|
|
321
|
+
.filter((b) => b.name !== 'master' && b.name !== '7.x')
|
|
322
|
+
.map((b) => {
|
|
323
|
+
return deleteBranch({
|
|
324
|
+
accessToken,
|
|
325
|
+
repoOwner: REPO_OWNER,
|
|
326
|
+
repoName: REPO_NAME,
|
|
327
|
+
branchName: b.name,
|
|
328
|
+
});
|
|
329
|
+
}));
|
|
330
|
+
const forkBranches = await getBranches({
|
|
321
331
|
accessToken,
|
|
322
|
-
repoOwner:
|
|
332
|
+
repoOwner: AUTHOR,
|
|
323
333
|
repoName: REPO_NAME,
|
|
324
|
-
branchName: BRANCH_NAME,
|
|
325
334
|
});
|
|
326
|
-
|
|
335
|
+
// delete all branches except master and 7.x
|
|
336
|
+
await Promise.all(forkBranches
|
|
337
|
+
.filter((b) => b.name !== 'master' && b.name !== '7.x')
|
|
338
|
+
.map((b) => {
|
|
339
|
+
return deleteBranch({
|
|
340
|
+
accessToken,
|
|
341
|
+
repoOwner: AUTHOR,
|
|
342
|
+
repoName: REPO_NAME,
|
|
343
|
+
branchName: b.name,
|
|
344
|
+
});
|
|
345
|
+
}));
|
|
346
|
+
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
327
347
|
}
|
package/dist/{scripts/generate-gql.d.ts → test/handleUnbackportedPullRequests.private.test.d.ts}
RENAMED
|
File without changes
|