backport 5.6.3 → 6.0.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 +48 -39
- package/dist/entrypoint.cli.js +1 -1
- package/dist/entrypoint.module.d.ts +6 -5
- package/dist/entrypoint.module.js +8 -6
- package/dist/ink.d.ts +1 -0
- package/dist/ink.js +49 -0
- package/dist/main.d.ts +11 -6
- package/dist/main.js +40 -24
- package/dist/options/ConfigOptions.d.ts +47 -39
- package/dist/options/cliArgs.d.ts +28 -34
- package/dist/options/cliArgs.js +113 -94
- package/dist/options/cliArgs.test.js +103 -119
- package/dist/options/config/config.d.ts +81 -2
- package/dist/options/config/config.js +46 -6
- package/dist/options/config/config.test.js +24 -2
- package/dist/options/config/getOptionsFromGit.d.ts +3 -0
- package/dist/options/config/getOptionsFromGit.js +10 -0
- package/dist/options/config/globalConfig.d.ts +2 -1
- package/dist/options/config/globalConfig.js +8 -8
- package/dist/options/config/globalConfig.test.js +7 -3
- package/dist/options/config/projectConfig.d.ts +2 -1
- package/dist/options/config/projectConfig.js +3 -3
- package/dist/options/config/projectConfig.test.js +4 -4
- package/dist/options/config/readConfigFile.d.ts +2 -2
- package/dist/options/config/readConfigFile.js +3 -3
- package/dist/options/options.d.ts +40 -27
- package/dist/options/options.js +8 -16
- package/dist/options/options.test.js +66 -26
- package/dist/options/parseRequiredOptions.d.ts +71 -0
- package/dist/options/parseRequiredOptions.js +70 -0
- package/dist/options/parseRequiredOptions.test.d.ts +1 -0
- package/dist/options/parseRequiredOptions.test.js +127 -0
- package/dist/runSequentially.d.ts +20 -0
- package/dist/runSequentially.js +41 -0
- package/dist/runSequentially.test.d.ts +1 -0
- package/dist/runSequentially.test.js +235 -0
- package/dist/runWithOptions.js +7 -14
- package/dist/runWithOptions.test.js +142 -16
- package/dist/scripts/generate-gql.d.ts +1 -0
- package/dist/scripts/generate-gql.js +15 -0
- package/dist/scripts/postinstall.js +4 -4
- package/dist/scripts/postinstall.test.js +9 -2
- package/dist/scripts/runPostinstall.js +1 -1
- package/dist/services/HandledError.d.ts +11 -1
- package/dist/services/HandledError.js +2 -1
- package/dist/services/child-process-promisified.d.ts +1 -1
- package/dist/services/child-process-promisified.js +2 -2
- package/dist/services/env.js +5 -5
- package/dist/services/env.test.js +11 -4
- package/dist/services/fs-promisified.js +4 -4
- package/dist/services/getExpectedTarget.d.ts +9 -0
- package/dist/services/getExpectedTarget.js +77 -0
- package/dist/services/getExpectedTargetPullRequests.d.ts +9 -0
- package/dist/services/getExpectedTargetPullRequests.js +77 -0
- package/dist/services/git.d.ts +19 -4
- package/dist/services/git.integration.test.d.ts +1 -0
- package/dist/services/git.integration.test.js +168 -0
- package/dist/services/git.js +129 -57
- package/dist/services/git.test.js +155 -51
- package/dist/services/github/commitFormatters.d.ts +3 -7
- package/dist/services/github/commitFormatters.js +10 -19
- package/dist/services/github/commitFormatters.test.js +2 -24
- package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.js +2 -6
- package/dist/services/github/v3/addAssigneesToPullRequest.test.js +2 -3
- package/dist/services/github/v3/addLabelsToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addLabelsToPullRequest.js +2 -6
- package/dist/services/github/v3/addReviewersToPullRequest.d.ts +2 -0
- package/dist/services/github/v3/addReviewersToPullRequest.js +34 -0
- package/dist/services/github/v3/createPullRequest.d.ts +3 -2
- package/dist/services/github/v3/createPullRequest.js +33 -24
- package/dist/services/github/v3/createStatusComment.d.ts +11 -0
- package/dist/services/github/v3/createStatusComment.js +97 -0
- package/dist/services/github/v3/createStatusComment.test.d.ts +1 -0
- package/dist/services/github/v3/createStatusComment.test.js +209 -0
- package/dist/services/github/v4/FetchPullRequestId.d.ts +9 -0
- package/dist/services/github/v4/FetchPullRequestId.js +32 -0
- package/dist/services/github/v4/apiRequestV4.d.ts +1 -1
- package/dist/services/github/v4/apiRequestV4.js +8 -10
- package/dist/services/github/v4/apiRequestV4.test.js +7 -7
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +9 -0
- package/dist/services/github/v4/disablePullRequestAutoMerge.js +28 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +9 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +51 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +113 -0
- package/dist/services/github/v4/fetchAuthorId.d.ts +5 -0
- package/dist/services/github/v4/fetchAuthorId.js +1 -1
- package/dist/services/github/v4/fetchAuthorId.private.test.js +3 -3
- package/dist/services/github/v4/fetchCommitByPullNumber.js +11 -9
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.js +6 -6
- package/dist/services/github/v4/fetchCommitBySha.js +14 -12
- package/dist/services/github/v4/fetchCommitBySha.private.test.js +7 -5
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +5 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +46 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +67 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +5 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +36 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +55 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +16 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +90 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +130 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +127 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.d.ts +28 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.js +52 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +10 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +49 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +81 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.js +252 -0
- package/dist/services/github/v4/fetchCommitsByAuthor.d.ts +3 -2
- package/dist/services/github/v4/fetchCommitsByAuthor.js +81 -70
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +81 -8
- package/dist/services/github/v4/fetchCommitsByAuthor.test.js +29 -21
- package/dist/services/github/v4/fetchDefaultBranch.d.ts +1 -1
- package/dist/services/github/v4/fetchDefaultBranch.js +1 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +4 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.js +52 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +32 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.d.ts +4 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.js +72 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.js +34 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.d.ts +40 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.js +72 -0
- package/dist/services/github/v4/fetchExistingPullRequest.js +2 -3
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +3 -3
- package/dist/services/github/v4/fetchMergedPullRequests.d.ts +19 -20
- package/dist/services/github/v4/fetchMergedPullRequests.js +22 -68
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.js +8 -9
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +11 -0
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +35 -0
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.d.ts +1 -1
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +12 -10
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +8 -6
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.js +2 -2
- package/dist/services/github/v4/getExistingTargetPullRequests.d.ts +4 -58
- package/dist/services/github/v4/getExistingTargetPullRequests.js +3 -58
- package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +61 -0
- package/dist/services/github/v4/getOptionsFromGithub/index.js +139 -0
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.d.ts +1 -0
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +126 -0
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +34 -0
- package/dist/services/github/v4/getOptionsFromGithub/query.js +44 -0
- package/dist/services/github/v4/getTargetBranchesFromLabels.d.ts +0 -7
- package/dist/services/github/v4/getTargetBranchesFromLabels.js +1 -26
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.js +69 -32
- package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +2 -2
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +39 -25
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.d.ts +2 -2
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +10 -0
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +2 -2
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +4 -1
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.d.ts +1 -1
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.js +1 -0
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +1 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -15
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +7 -7
- package/dist/services/logger.d.ts +3 -3
- package/dist/services/logger.js +24 -24
- package/dist/services/prompt.test.d.ts +1 -0
- package/dist/services/prompt.test.js +87 -0
- package/dist/services/prompts.d.ts +10 -4
- package/dist/services/prompts.js +85 -22
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +9 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +92 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +396 -0
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +21 -0
- package/dist/services/sourceCommit/getMockSourceCommit.js +67 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.d.ts +5 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.js +20 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.d.ts +1 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.js +201 -0
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +78 -0
- package/dist/services/sourceCommit/parseSourceCommit.js +96 -0
- package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +1 -0
- package/dist/services/sourceCommit/parseSourceCommit.test.js +114 -0
- package/dist/services/sourceCommit/sourceCommit.d.ts +78 -0
- package/dist/services/sourceCommit/sourceCommit.js +86 -0
- package/dist/services/sourceCommit/sourceCommit.test.d.ts +1 -0
- package/dist/services/sourceCommit/sourceCommit.test.js +287 -0
- package/dist/services/sourceCommit.d.ts +78 -0
- package/dist/services/sourceCommit.js +86 -0
- package/dist/services/sourceCommit.test.d.ts +1 -0
- package/dist/services/sourceCommit.test.js +280 -0
- package/dist/test/inquirer.private.test.js +81 -45
- package/dist/test/integration/createSpies.d.ts +1 -1
- package/dist/test/integration/createSpies.js +21 -9
- package/dist/test/integration/envConstants.js +5 -6
- package/dist/test/integration/helpers.js +1 -1
- package/dist/test/integration/integration.private.test.d.ts +1 -0
- package/dist/test/integration/integration.private.test.js +308 -0
- package/dist/test/integration/integration.test.js +30 -31
- package/dist/test/nockHelpers.d.ts +2 -2
- package/dist/test/nockHelpers.js +3 -7
- package/dist/test/setupFiles/automatic-mocks.d.ts +0 -1
- package/dist/test/setupFiles/automatic-mocks.js +0 -22
- package/dist/types/Commit.d.ts +85 -0
- package/dist/types/Commit.js +139 -0
- package/dist/types/commitNode.d.ts +89 -0
- package/dist/types/commitNode.js +139 -0
- package/dist/types/commitNode.test.d.ts +1 -0
- package/dist/types/commitNode.test.js +255 -0
- package/dist/types/commitWithAssociatedPullRequests.d.ts +86 -0
- package/dist/types/commitWithAssociatedPullRequests.js +145 -0
- package/dist/ui/cherrypickAndCreatePullRequest.test.js +277 -59
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +11 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +135 -67
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +468 -0
- package/dist/ui/getCommits.d.ts +1 -1
- package/dist/ui/getCommits.js +55 -25
- package/dist/ui/getTargetBranches.d.ts +2 -2
- package/dist/ui/getTargetBranches.js +16 -17
- package/dist/ui/getTargetBranches.test.js +75 -99
- package/dist/ui/getTargetBranchesFromLabels.d.ts +6 -0
- package/dist/ui/getTargetBranchesFromLabels.js +40 -0
- package/dist/ui/getTargetBranchesFromLabels.test.d.ts +1 -0
- package/dist/ui/getTargetBranchesFromLabels.test.js +288 -0
- package/dist/ui/maybeSetupRepo.js +9 -9
- package/dist/ui/maybeSetupRepo.test.js +5 -1
- package/package.json +36 -51
- package/yarn.lock +2387 -2979
|
@@ -20,6 +20,7 @@ const defaultOptions = {
|
|
|
20
20
|
maxNumber: 10,
|
|
21
21
|
githubApiBaseUrlV3: 'https://api.github.com',
|
|
22
22
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
23
|
+
commitPaths: [],
|
|
23
24
|
};
|
|
24
25
|
const authorIdMockData = { user: { id: 'myUserId' } };
|
|
25
26
|
describe('fetchCommitsByAuthor', () => {
|
|
@@ -34,21 +35,22 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
34
35
|
let authorIdCalls;
|
|
35
36
|
let commitsByAuthorCalls;
|
|
36
37
|
beforeEach(async () => {
|
|
37
|
-
authorIdCalls = nockHelpers_1.mockGqlRequest({
|
|
38
|
+
authorIdCalls = (0, nockHelpers_1.mockGqlRequest)({
|
|
38
39
|
name: 'AuthorId',
|
|
39
40
|
statusCode: 200,
|
|
40
41
|
body: { data: authorIdMockData },
|
|
41
42
|
});
|
|
42
|
-
commitsByAuthorCalls = nockHelpers_1.mockGqlRequest({
|
|
43
|
+
commitsByAuthorCalls = (0, nockHelpers_1.mockGqlRequest)({
|
|
43
44
|
name: 'CommitsByAuthor',
|
|
44
45
|
statusCode: 200,
|
|
45
46
|
body: { data: commitsByAuthorMock_1.commitsWithPullRequestsMock },
|
|
46
47
|
});
|
|
47
|
-
res = await fetchCommitsByAuthor_1.fetchCommitsByAuthor(defaultOptions);
|
|
48
|
+
res = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)(defaultOptions);
|
|
48
49
|
});
|
|
49
|
-
it('
|
|
50
|
+
it('should return a list of commits with pullNumber and existing backports', () => {
|
|
50
51
|
const expectedCommits = [
|
|
51
52
|
{
|
|
53
|
+
committedDate: '2021-12-24T00:00:00Z',
|
|
52
54
|
sha: '2e63475c483f7844b0f2833bc57fdee32095bacb',
|
|
53
55
|
formattedMessage: 'Add 👻 (2e63475c)',
|
|
54
56
|
originalMessage: 'Add 👻',
|
|
@@ -57,6 +59,7 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
57
59
|
sourceBranch: 'master',
|
|
58
60
|
},
|
|
59
61
|
{
|
|
62
|
+
committedDate: '2021-12-23T00:00:00Z',
|
|
60
63
|
sha: 'f3b618b9421fdecdb36862f907afbdd6344b361d',
|
|
61
64
|
formattedMessage: 'Add witch (#85)',
|
|
62
65
|
originalMessage: 'Add witch (#85)',
|
|
@@ -66,6 +69,7 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
66
69
|
sourceBranch: 'master',
|
|
67
70
|
},
|
|
68
71
|
{
|
|
72
|
+
committedDate: '2021-12-22T00:00:00Z',
|
|
69
73
|
sha: '79cf18453ec32a4677009dcbab1c9c8c73fc14fe',
|
|
70
74
|
formattedMessage: 'Add SF mention (#80)',
|
|
71
75
|
originalMessage: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
|
|
@@ -77,6 +81,7 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
77
81
|
sourceBranch: 'master',
|
|
78
82
|
},
|
|
79
83
|
{
|
|
84
|
+
committedDate: '2021-12-21T00:00:00Z',
|
|
80
85
|
sha: '3827bbbaf39914eda4f02f6940189844375fd097',
|
|
81
86
|
formattedMessage: 'Add backport config (3827bbba)',
|
|
82
87
|
originalMessage: 'Add backport config',
|
|
@@ -85,6 +90,7 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
85
90
|
sourceBranch: 'master',
|
|
86
91
|
},
|
|
87
92
|
{
|
|
93
|
+
committedDate: '2021-12-20T00:00:00Z',
|
|
88
94
|
sha: '5ea0da550ac191029459289d67f99ad7d310812b',
|
|
89
95
|
formattedMessage: 'Initial commit (5ea0da55)',
|
|
90
96
|
originalMessage: 'Initial commit',
|
|
@@ -107,6 +113,7 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
107
113
|
const res = await getExistingBackportsByRepoName('kibana', 'kibana');
|
|
108
114
|
const expectedCommits = [
|
|
109
115
|
{
|
|
116
|
+
committedDate: '2021-12-13T22:46:29Z',
|
|
110
117
|
existingTargetPullRequests: [
|
|
111
118
|
{ branch: '6.3', state: 'MERGED', number: 99 },
|
|
112
119
|
],
|
|
@@ -124,6 +131,7 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
124
131
|
const res = await getExistingBackportsByRepoName('kibana', 'kibana2');
|
|
125
132
|
const expectedCommits = [
|
|
126
133
|
{
|
|
134
|
+
committedDate: '2021-12-13T22:46:29Z',
|
|
127
135
|
existingTargetPullRequests: [],
|
|
128
136
|
formattedMessage: 'Add SF mention (#80)',
|
|
129
137
|
originalMessage: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
|
|
@@ -138,19 +146,19 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
138
146
|
});
|
|
139
147
|
describe('when a custom github api hostname is supplied', () => {
|
|
140
148
|
it('should be used in gql requests', async () => {
|
|
141
|
-
const authorIdCalls = nockHelpers_1.mockGqlRequest({
|
|
149
|
+
const authorIdCalls = (0, nockHelpers_1.mockGqlRequest)({
|
|
142
150
|
name: 'AuthorId',
|
|
143
151
|
statusCode: 200,
|
|
144
152
|
body: { data: authorIdMockData },
|
|
145
153
|
apiBaseUrl: 'http://localhost/my-custom-api',
|
|
146
154
|
});
|
|
147
|
-
const commitsByAuthorCalls = nockHelpers_1.mockGqlRequest({
|
|
155
|
+
const commitsByAuthorCalls = (0, nockHelpers_1.mockGqlRequest)({
|
|
148
156
|
name: 'CommitsByAuthor',
|
|
149
157
|
statusCode: 200,
|
|
150
158
|
body: { data: commitsByAuthorMock_1.commitsWithPullRequestsMock },
|
|
151
159
|
apiBaseUrl: 'http://localhost/my-custom-api',
|
|
152
160
|
});
|
|
153
|
-
await fetchCommitsByAuthor_1.fetchCommitsByAuthor({
|
|
161
|
+
await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
154
162
|
...defaultOptions,
|
|
155
163
|
githubApiBaseUrlV4: 'http://localhost/my-custom-api',
|
|
156
164
|
});
|
|
@@ -164,7 +172,7 @@ describe('getExistingTargetPullRequests', () => {
|
|
|
164
172
|
nock_1.default.cleanAll();
|
|
165
173
|
});
|
|
166
174
|
it('should return a result when commit messages match', () => {
|
|
167
|
-
const pullRequestNode = getPullRequestNodeMock_1.getPullRequestNodeMock({
|
|
175
|
+
const pullRequestNode = (0, getPullRequestNodeMock_1.getPullRequestNodeMock)({
|
|
168
176
|
sourcePullRequest: {
|
|
169
177
|
number: 1234,
|
|
170
178
|
commitMessage: 'my message (#1234)',
|
|
@@ -175,13 +183,13 @@ describe('getExistingTargetPullRequests', () => {
|
|
|
175
183
|
commitMessages: ['my message (#1234)'],
|
|
176
184
|
},
|
|
177
185
|
});
|
|
178
|
-
const existingPRs = getExistingTargetPullRequests_1.getExistingTargetPullRequests(pullRequestNode);
|
|
186
|
+
const existingPRs = (0, getExistingTargetPullRequests_1.getExistingTargetPullRequests)(pullRequestNode);
|
|
179
187
|
expect(existingPRs).toEqual([
|
|
180
188
|
{ branch: '7.x', state: 'MERGED', number: 10 },
|
|
181
189
|
]);
|
|
182
190
|
});
|
|
183
191
|
it('should not return a result when commit messages do not match', () => {
|
|
184
|
-
const pullRequestNode = getPullRequestNodeMock_1.getPullRequestNodeMock({
|
|
192
|
+
const pullRequestNode = (0, getPullRequestNodeMock_1.getPullRequestNodeMock)({
|
|
185
193
|
sourcePullRequest: {
|
|
186
194
|
number: 1234,
|
|
187
195
|
commitMessage: 'the initial message',
|
|
@@ -192,11 +200,11 @@ describe('getExistingTargetPullRequests', () => {
|
|
|
192
200
|
commitMessages: ['my changed message (#1234)'],
|
|
193
201
|
},
|
|
194
202
|
});
|
|
195
|
-
const existingPRs = getExistingTargetPullRequests_1.getExistingTargetPullRequests(pullRequestNode);
|
|
203
|
+
const existingPRs = (0, getExistingTargetPullRequests_1.getExistingTargetPullRequests)(pullRequestNode);
|
|
196
204
|
expect(existingPRs).toEqual([]);
|
|
197
205
|
});
|
|
198
206
|
it('should return a result when commit message matches pull request title and number', () => {
|
|
199
|
-
const pullRequestNode = getPullRequestNodeMock_1.getPullRequestNodeMock({
|
|
207
|
+
const pullRequestNode = (0, getPullRequestNodeMock_1.getPullRequestNodeMock)({
|
|
200
208
|
sourcePullRequest: {
|
|
201
209
|
number: 1234,
|
|
202
210
|
commitMessage: 'the initial message',
|
|
@@ -207,13 +215,13 @@ describe('getExistingTargetPullRequests', () => {
|
|
|
207
215
|
commitMessages: ['the actual message'],
|
|
208
216
|
},
|
|
209
217
|
});
|
|
210
|
-
const existingPRs = getExistingTargetPullRequests_1.getExistingTargetPullRequests(pullRequestNode);
|
|
218
|
+
const existingPRs = (0, getExistingTargetPullRequests_1.getExistingTargetPullRequests)(pullRequestNode);
|
|
211
219
|
expect(existingPRs).toEqual([
|
|
212
220
|
{ branch: '7.x', state: 'MERGED', number: 40 },
|
|
213
221
|
]);
|
|
214
222
|
});
|
|
215
223
|
it('should not return a result when only pull request title (but not pull number) matches', () => {
|
|
216
|
-
const pullRequestNode = getPullRequestNodeMock_1.getPullRequestNodeMock({
|
|
224
|
+
const pullRequestNode = (0, getPullRequestNodeMock_1.getPullRequestNodeMock)({
|
|
217
225
|
sourcePullRequest: {
|
|
218
226
|
number: 1234,
|
|
219
227
|
commitMessage: 'my message',
|
|
@@ -224,11 +232,11 @@ describe('getExistingTargetPullRequests', () => {
|
|
|
224
232
|
commitMessages: ['the actual message'],
|
|
225
233
|
},
|
|
226
234
|
});
|
|
227
|
-
const existingPRs = getExistingTargetPullRequests_1.getExistingTargetPullRequests(pullRequestNode);
|
|
235
|
+
const existingPRs = (0, getExistingTargetPullRequests_1.getExistingTargetPullRequests)(pullRequestNode);
|
|
228
236
|
expect(existingPRs).toEqual([]);
|
|
229
237
|
});
|
|
230
238
|
it('should return a result when first line of a multiline commit message matches', () => {
|
|
231
|
-
const pullRequestNode = getPullRequestNodeMock_1.getPullRequestNodeMock({
|
|
239
|
+
const pullRequestNode = (0, getPullRequestNodeMock_1.getPullRequestNodeMock)({
|
|
232
240
|
sourcePullRequest: {
|
|
233
241
|
number: 1234,
|
|
234
242
|
commitMessage: 'my message (#1234)',
|
|
@@ -239,25 +247,25 @@ describe('getExistingTargetPullRequests', () => {
|
|
|
239
247
|
commitMessages: ['my message (#1234)\n\nsomething else'],
|
|
240
248
|
},
|
|
241
249
|
});
|
|
242
|
-
const existingPRs = getExistingTargetPullRequests_1.getExistingTargetPullRequests(pullRequestNode);
|
|
250
|
+
const existingPRs = (0, getExistingTargetPullRequests_1.getExistingTargetPullRequests)(pullRequestNode);
|
|
243
251
|
expect(existingPRs).toEqual([
|
|
244
252
|
{ branch: '7.x', state: 'MERGED', number: 20 },
|
|
245
253
|
]);
|
|
246
254
|
});
|
|
247
255
|
});
|
|
248
256
|
async function getExistingBackportsByRepoName(repoName1, repoName2) {
|
|
249
|
-
const commitsMock = getCommitsByAuthorMock_1.getCommitsByAuthorMock(repoName1);
|
|
250
|
-
nockHelpers_1.mockGqlRequest({
|
|
257
|
+
const commitsMock = (0, getCommitsByAuthorMock_1.getCommitsByAuthorMock)(repoName1);
|
|
258
|
+
(0, nockHelpers_1.mockGqlRequest)({
|
|
251
259
|
name: 'AuthorId',
|
|
252
260
|
statusCode: 200,
|
|
253
261
|
body: { data: authorIdMockData },
|
|
254
262
|
});
|
|
255
|
-
nockHelpers_1.mockGqlRequest({
|
|
263
|
+
(0, nockHelpers_1.mockGqlRequest)({
|
|
256
264
|
name: 'CommitsByAuthor',
|
|
257
265
|
statusCode: 200,
|
|
258
266
|
body: { data: commitsMock },
|
|
259
267
|
});
|
|
260
|
-
return fetchCommitsByAuthor_1.fetchCommitsByAuthor({
|
|
268
|
+
return (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
261
269
|
...defaultOptions,
|
|
262
270
|
repoName: repoName2,
|
|
263
271
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../../../options/options';
|
|
2
2
|
export declare function fetchDefaultBranch(options: ValidConfigOptions): Promise<string>;
|
|
3
|
-
export interface
|
|
3
|
+
export interface DefaultBranchResoonse {
|
|
4
4
|
repo: {
|
|
5
5
|
defaultBranchRef: {
|
|
6
6
|
name: string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetchDefaultRepoBranchAndPerformStartupChecks = void 0;
|
|
7
|
+
const ora_1 = __importDefault(require("ora"));
|
|
8
|
+
const HandledError_1 = require("../../../HandledError");
|
|
9
|
+
const apiRequestV4_1 = require("../apiRequestV4");
|
|
10
|
+
const throwOnInvalidAccessToken_1 = require("../throwOnInvalidAccessToken");
|
|
11
|
+
const query_1 = require("./query");
|
|
12
|
+
// fetches the default source branch for the repo (normally "master")
|
|
13
|
+
// startup checks:
|
|
14
|
+
// - verify the access token
|
|
15
|
+
// - ensure no branch named "backport" exists
|
|
16
|
+
async function fetchDefaultRepoBranchAndPerformStartupChecks({ accessToken, githubApiBaseUrlV4, repoName, repoOwner, }) {
|
|
17
|
+
var _a;
|
|
18
|
+
let res;
|
|
19
|
+
const spinner = ora_1.default().start('Initializing...');
|
|
20
|
+
try {
|
|
21
|
+
res = await apiRequestV4_1.apiRequestV4({
|
|
22
|
+
githubApiBaseUrlV4,
|
|
23
|
+
accessToken,
|
|
24
|
+
query: query_1.query,
|
|
25
|
+
variables: {
|
|
26
|
+
repoOwner,
|
|
27
|
+
repoName,
|
|
28
|
+
},
|
|
29
|
+
handleError: false,
|
|
30
|
+
});
|
|
31
|
+
spinner.stop();
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
spinner.stop();
|
|
35
|
+
const error = e;
|
|
36
|
+
throwOnInvalidAccessToken_1.throwOnInvalidAccessToken({
|
|
37
|
+
error,
|
|
38
|
+
repoName,
|
|
39
|
+
repoOwner,
|
|
40
|
+
});
|
|
41
|
+
throw apiRequestV4_1.handleGithubV4Error(error);
|
|
42
|
+
}
|
|
43
|
+
// it is not possible to have a branch named "backport"
|
|
44
|
+
if (((_a = res.repository.ref) === null || _a === void 0 ? void 0 : _a.name) === 'backport') {
|
|
45
|
+
throw new HandledError_1.HandledError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
46
|
+
}
|
|
47
|
+
// return default branch
|
|
48
|
+
return {
|
|
49
|
+
defaultBranch: res.repository.defaultBranchRef.name,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
exports.fetchDefaultRepoBranchAndPerformStartupChecks = fetchDefaultRepoBranchAndPerformStartupChecks;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
4
|
+
const fetchDefaultRepoBranchAndPerformStartupChecks_1 = require("./fetchDefaultRepoBranchAndPerformStartupChecks");
|
|
5
|
+
describe('fetchDefaultRepoBranchAndPerformStartupChecks', () => {
|
|
6
|
+
let devAccessToken;
|
|
7
|
+
beforeAll(async () => {
|
|
8
|
+
devAccessToken = await getDevAccessToken_1.getDevAccessToken();
|
|
9
|
+
});
|
|
10
|
+
describe('accessToken is invalid', () => {
|
|
11
|
+
it('throws an error', async () => {
|
|
12
|
+
const options = {
|
|
13
|
+
accessToken: 'foo',
|
|
14
|
+
githubApiBaseUrlV4: 'https://api.github.com/graphql',
|
|
15
|
+
repoName: 'backport-e2e',
|
|
16
|
+
repoOwner: 'backport-org',
|
|
17
|
+
};
|
|
18
|
+
await expect(fetchDefaultRepoBranchAndPerformStartupChecks_1.fetchDefaultRepoBranchAndPerformStartupChecks(options)).rejects.toThrowError('Please check your access token and make sure it is valid.\nConfig: /myHomeDir/.backport/config.json');
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe('accessToken is valid', () => {
|
|
22
|
+
it('returns the default branch', async () => {
|
|
23
|
+
const options = {
|
|
24
|
+
accessToken: devAccessToken,
|
|
25
|
+
githubApiBaseUrlV4: 'https://api.github.com/graphql',
|
|
26
|
+
repoName: 'backport-e2e',
|
|
27
|
+
repoOwner: 'backport-org',
|
|
28
|
+
};
|
|
29
|
+
expect(await fetchDefaultRepoBranchAndPerformStartupChecks_1.fetchDefaultRepoBranchAndPerformStartupChecks(options)).toEqual({ defaultBranch: 'master' });
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getOptionsFromGithub = void 0;
|
|
7
|
+
const ora_1 = __importDefault(require("ora"));
|
|
8
|
+
const HandledError_1 = require("../../../HandledError");
|
|
9
|
+
const git_1 = require("../../../git");
|
|
10
|
+
const apiRequestV4_1 = require("../apiRequestV4");
|
|
11
|
+
const throwOnInvalidAccessToken_1 = require("../throwOnInvalidAccessToken");
|
|
12
|
+
const query_1 = require("./query");
|
|
13
|
+
// fetches the default source branch for the repo (normally "master")
|
|
14
|
+
// startup checks:
|
|
15
|
+
// - verify the access token
|
|
16
|
+
// - ensure no branch named "backport" exists
|
|
17
|
+
async function getOptionsFromGithub(options) {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
const { accessToken, githubApiBaseUrlV4, repoName, repoOwner } = options;
|
|
20
|
+
let res;
|
|
21
|
+
const spinner = ora_1.default().start('Initializing...');
|
|
22
|
+
try {
|
|
23
|
+
res = await apiRequestV4_1.apiRequestV4({
|
|
24
|
+
githubApiBaseUrlV4,
|
|
25
|
+
accessToken,
|
|
26
|
+
query: query_1.query,
|
|
27
|
+
variables: {
|
|
28
|
+
repoOwner,
|
|
29
|
+
repoName,
|
|
30
|
+
},
|
|
31
|
+
handleError: false,
|
|
32
|
+
});
|
|
33
|
+
spinner.stop();
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
spinner.stop();
|
|
37
|
+
const error = e;
|
|
38
|
+
throwOnInvalidAccessToken_1.throwOnInvalidAccessToken({
|
|
39
|
+
error,
|
|
40
|
+
repoName,
|
|
41
|
+
repoOwner,
|
|
42
|
+
});
|
|
43
|
+
throw apiRequestV4_1.handleGithubV4Error(error);
|
|
44
|
+
}
|
|
45
|
+
// get the original repo (not the fork)
|
|
46
|
+
const repo = res.repository.isFork ? res.repository.parent : res.repository;
|
|
47
|
+
// it is not possible to have a branch named "backport"
|
|
48
|
+
if (((_a = repo.ref) === null || _a === void 0 ? void 0 : _a.name) === 'backport') {
|
|
49
|
+
throw new HandledError_1.HandledError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
50
|
+
}
|
|
51
|
+
const remoteConfig = (_b = repo.defaultBranchRef.target.edges[0]) === null || _b === void 0 ? void 0 : _b.config;
|
|
52
|
+
const shouldUse = await shouldUseLocalConfig(options, remoteConfig);
|
|
53
|
+
// return default branch
|
|
54
|
+
return {
|
|
55
|
+
defaultBranch: repo.defaultBranchRef.name,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.getOptionsFromGithub = getOptionsFromGithub;
|
|
59
|
+
async function shouldUseLocalConfig(options, remoteConfig) {
|
|
60
|
+
if (options.useLocalConfig) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
const remoteCommitDate = remoteConfig === null || remoteConfig === void 0 ? void 0 : remoteConfig.committedDate;
|
|
64
|
+
if (!remoteCommitDate) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
const localCommitDate = await git_1.getLocalConfigFileCommitDate();
|
|
68
|
+
if (!localCommitDate) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return localCommitDate > Date.parse(remoteCommitDate);
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
describe('fetchDefaultRepoBranchAndPerformStartupChecks', () => {
|
|
6
|
+
let devAccessToken;
|
|
7
|
+
beforeAll(async () => {
|
|
8
|
+
devAccessToken = await getDevAccessToken_1.getDevAccessToken();
|
|
9
|
+
});
|
|
10
|
+
describe('accessToken is invalid', () => {
|
|
11
|
+
it('throws an error', async () => {
|
|
12
|
+
const options = {
|
|
13
|
+
accessToken: 'foo',
|
|
14
|
+
githubApiBaseUrlV4: 'https://api.github.com/graphql',
|
|
15
|
+
repoName: 'backport-e2e',
|
|
16
|
+
repoOwner: 'backport-org',
|
|
17
|
+
};
|
|
18
|
+
await expect(_1.getOptionsFromGithub(options)).rejects.toThrowError('Please check your access token and make sure it is valid.\nConfig: /myHomeDir/.backport/config.json');
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe('accessToken is valid', () => {
|
|
22
|
+
it('returns the default branch', async () => {
|
|
23
|
+
const options = {
|
|
24
|
+
accessToken: devAccessToken,
|
|
25
|
+
githubApiBaseUrlV4: 'https://api.github.com/graphql',
|
|
26
|
+
repoName: 'backport-e2e',
|
|
27
|
+
repoOwner: 'backport-org',
|
|
28
|
+
};
|
|
29
|
+
expect(await _1.getOptionsFromGithub(options)).toEqual({
|
|
30
|
+
defaultBranch: 'master',
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare type RemoteConfig = {
|
|
2
|
+
committedDate: string;
|
|
3
|
+
file: {
|
|
4
|
+
object: {
|
|
5
|
+
text: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
declare type Ref = {
|
|
10
|
+
name: string;
|
|
11
|
+
} | null;
|
|
12
|
+
declare type DefaultBranchRef = {
|
|
13
|
+
name: string;
|
|
14
|
+
target: {
|
|
15
|
+
edges: ({
|
|
16
|
+
config: RemoteConfig;
|
|
17
|
+
} | undefined)[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export interface DataResponse {
|
|
21
|
+
viewer: {
|
|
22
|
+
login: string;
|
|
23
|
+
};
|
|
24
|
+
repository: {
|
|
25
|
+
isFork: boolean;
|
|
26
|
+
id: string;
|
|
27
|
+
ref: Ref;
|
|
28
|
+
defaultBranchRef: DefaultBranchRef;
|
|
29
|
+
parent: {
|
|
30
|
+
id: string;
|
|
31
|
+
ref: Ref;
|
|
32
|
+
defaultBranchRef: DefaultBranchRef;
|
|
33
|
+
owner: {
|
|
34
|
+
login: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export declare const query = "\n query getStartupChecks($repoOwner: String!, $repoName: String!) {\n viewer {\n login\n }\n repository(owner: $repoOwner, name: $repoName) {\n isFork\n ...UpstreamInfo\n parent {\n ...UpstreamInfo\n owner {\n login\n }\n }\n }\n }\n\n fragment UpstreamInfo on Repository {\n id\n ref(qualifiedName: \"refs/heads/7.x\") {\n name\n }\n defaultBranchRef {\n name\n target {\n ...JSONConfigFile\n ...JSConfigFile\n }\n }\n }\n\n fragment JSONConfigFile on Commit {\n jsonConfigFile: history(first: 1, path: \".backportrc.json\") {\n edges {\n config: node {\n committedDate\n file(path: \".backportrc.json\") {\n ... on TreeEntry {\n object {\n ... on Blob {\n text\n }\n }\n }\n }\n }\n }\n }\n }\n\n fragment JSConfigFile on Commit {\n jsConfigFile: history(first: 1, path: \".backportrc.js\") {\n edges {\n config: node {\n committedDate\n file(path: \".backportrc.js\") {\n ... on TreeEntry {\n object {\n ... on Blob {\n text\n }\n }\n }\n }\n }\n }\n }\n }\n";
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.query = void 0;
|
|
4
|
+
exports.query = `
|
|
5
|
+
query getStartupChecks($repoOwner: String!, $repoName: String!) {
|
|
6
|
+
viewer {
|
|
7
|
+
login
|
|
8
|
+
}
|
|
9
|
+
repository(owner: $repoOwner, name: $repoName) {
|
|
10
|
+
isFork
|
|
11
|
+
...UpstreamInfo
|
|
12
|
+
parent {
|
|
13
|
+
...UpstreamInfo
|
|
14
|
+
owner {
|
|
15
|
+
login
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fragment UpstreamInfo on Repository {
|
|
22
|
+
id
|
|
23
|
+
ref(qualifiedName: "refs/heads/7.x") {
|
|
24
|
+
name
|
|
25
|
+
}
|
|
26
|
+
defaultBranchRef {
|
|
27
|
+
name
|
|
28
|
+
target {
|
|
29
|
+
...JSONConfigFile
|
|
30
|
+
...JSConfigFile
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fragment JSONConfigFile on Commit {
|
|
36
|
+
jsonConfigFile: history(first: 1, path: ".backportrc.json") {
|
|
37
|
+
edges {
|
|
38
|
+
config: node {
|
|
39
|
+
committedDate
|
|
40
|
+
file(path: ".backportrc.json") {
|
|
41
|
+
... on TreeEntry {
|
|
42
|
+
object {
|
|
43
|
+
... on Blob {
|
|
44
|
+
text
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fragment JSConfigFile on Commit {
|
|
55
|
+
jsConfigFile: history(first: 1, path: ".backportrc.js") {
|
|
56
|
+
edges {
|
|
57
|
+
config: node {
|
|
58
|
+
committedDate
|
|
59
|
+
file(path: ".backportrc.js") {
|
|
60
|
+
... on TreeEntry {
|
|
61
|
+
object {
|
|
62
|
+
... on Blob {
|
|
63
|
+
text
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.splitHead = exports.fetchExistingPullRequest = void 0;
|
|
4
4
|
const apiRequestV4_1 = require("./apiRequestV4");
|
|
5
5
|
async function fetchExistingPullRequest({ options, prPayload, }) {
|
|
6
|
-
var _a;
|
|
7
6
|
const { githubApiBaseUrlV4, accessToken } = options;
|
|
8
7
|
const query = /* GraphQL */ `
|
|
9
8
|
query ExistingPullRequest(
|
|
@@ -34,7 +33,7 @@ async function fetchExistingPullRequest({ options, prPayload, }) {
|
|
|
34
33
|
}
|
|
35
34
|
`;
|
|
36
35
|
const { repoForkOwner, head } = splitHead(prPayload);
|
|
37
|
-
const res = await apiRequestV4_1.apiRequestV4({
|
|
36
|
+
const res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
38
37
|
githubApiBaseUrlV4,
|
|
39
38
|
accessToken,
|
|
40
39
|
query,
|
|
@@ -45,7 +44,7 @@ async function fetchExistingPullRequest({ options, prPayload, }) {
|
|
|
45
44
|
head: head,
|
|
46
45
|
},
|
|
47
46
|
});
|
|
48
|
-
const existingPullRequest =
|
|
47
|
+
const existingPullRequest = res.repository.ref?.associatedPullRequests.edges[0];
|
|
49
48
|
if (!existingPullRequest) {
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
@@ -5,7 +5,7 @@ const fetchExistingPullRequest_1 = require("./fetchExistingPullRequest");
|
|
|
5
5
|
describe('fetchExistingPullRequest', () => {
|
|
6
6
|
let devAccessToken;
|
|
7
7
|
beforeAll(async () => {
|
|
8
|
-
devAccessToken = await getDevAccessToken_1.getDevAccessToken();
|
|
8
|
+
devAccessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
9
|
});
|
|
10
10
|
describe('when PR does not exist', () => {
|
|
11
11
|
it('returns undefined', async () => {
|
|
@@ -21,7 +21,7 @@ describe('fetchExistingPullRequest', () => {
|
|
|
21
21
|
head: 'sqren:backport/7.8/pr-foo',
|
|
22
22
|
base: '7.8',
|
|
23
23
|
};
|
|
24
|
-
const res = await fetchExistingPullRequest_1.fetchExistingPullRequest({ options, prPayload });
|
|
24
|
+
const res = await (0, fetchExistingPullRequest_1.fetchExistingPullRequest)({ options, prPayload });
|
|
25
25
|
expect(res).toBe(undefined);
|
|
26
26
|
});
|
|
27
27
|
});
|
|
@@ -39,7 +39,7 @@ describe('fetchExistingPullRequest', () => {
|
|
|
39
39
|
head: 'sqren:backport/7.8/pr-9',
|
|
40
40
|
base: '7.8',
|
|
41
41
|
};
|
|
42
|
-
const res = await fetchExistingPullRequest_1.fetchExistingPullRequest({ options, prPayload });
|
|
42
|
+
const res = await (0, fetchExistingPullRequest_1.fetchExistingPullRequest)({ options, prPayload });
|
|
43
43
|
expect(res).toEqual({
|
|
44
44
|
url: 'https://github.com/backport-org/backport-e2e/pull/10',
|
|
45
45
|
number: 10,
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../../../options/options';
|
|
2
|
-
import {
|
|
3
|
-
export declare function fetchMergedPullRequests(
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { CommitNode } from '../../../types/commitNode';
|
|
3
|
+
export declare function fetchMergedPullRequests({ accessToken, branchLabelMapping, commitsCount, dateRange, githubApiBaseUrlV4, repoName, repoOwner, sourceBranch, }: {
|
|
4
|
+
accessToken: string;
|
|
5
|
+
branchLabelMapping: ValidConfigOptions['branchLabelMapping'];
|
|
6
|
+
commitsCount?: number;
|
|
7
|
+
dateRange: {
|
|
8
|
+
since: string;
|
|
9
|
+
until: string;
|
|
10
|
+
};
|
|
11
|
+
githubApiBaseUrlV4?: string;
|
|
12
|
+
repoName: string;
|
|
13
|
+
repoOwner: string;
|
|
14
|
+
sourceBranch: string;
|
|
6
15
|
}): Promise<{
|
|
7
|
-
sourcePullNumber: number;
|
|
16
|
+
sourcePullNumber: number | undefined;
|
|
8
17
|
existingTargetPullRequests: {
|
|
9
18
|
number: number;
|
|
10
19
|
branch: string;
|
|
@@ -12,27 +21,17 @@ export declare function fetchMergedPullRequests(options: ValidConfigOptions, dat
|
|
|
12
21
|
}[];
|
|
13
22
|
expectedTargetBranches: string[];
|
|
14
23
|
remainingTargetBranches: string[];
|
|
15
|
-
}[]
|
|
16
|
-
export interface
|
|
24
|
+
}[]>;
|
|
25
|
+
export interface CommitsSinceDateResponse {
|
|
17
26
|
repository: {
|
|
18
27
|
ref: {
|
|
19
28
|
target: {
|
|
20
29
|
history: {
|
|
21
|
-
edges:
|
|
30
|
+
edges: Array<{
|
|
31
|
+
node: CommitNode;
|
|
32
|
+
}>;
|
|
22
33
|
};
|
|
23
34
|
};
|
|
24
35
|
} | null;
|
|
25
36
|
};
|
|
26
37
|
}
|
|
27
|
-
interface HistoryEdge {
|
|
28
|
-
node: {
|
|
29
|
-
oid: string;
|
|
30
|
-
message: string;
|
|
31
|
-
associatedPullRequests: {
|
|
32
|
-
edges: {
|
|
33
|
-
node: PullRequestNode;
|
|
34
|
-
}[];
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export {};
|