backport 8.4.3 → 8.5.1

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.
Files changed (53) hide show
  1. package/dist/entrypoint.module.d.ts +2 -2
  2. package/dist/entrypoint.module.js +9 -8
  3. package/dist/entrypoint.module.private.test.js +79 -29
  4. package/dist/lib/cherrypickAndCreateTargetPullRequest.js +1 -1
  5. package/dist/lib/cherrypickAndCreateTargetPullRequest.test.js +12 -4
  6. package/dist/lib/child-process-promisified.d.ts +1 -1
  7. package/dist/lib/child-process-promisified.js +14 -3
  8. package/dist/lib/getCommits.js +14 -9
  9. package/dist/lib/getCommitsWithoutBackports.js +3 -3
  10. package/dist/lib/getCommitsWithoutBackports.test.js +38 -15
  11. package/dist/lib/getTargetBranches.d.ts +1 -1
  12. package/dist/lib/getTargetBranches.js +6 -10
  13. package/dist/lib/getTargetBranches.test.js +9 -5
  14. package/dist/lib/git.d.ts +2 -2
  15. package/dist/lib/git.js +1 -1
  16. package/dist/lib/git.private.test.js +18 -1
  17. package/dist/lib/git.test.js +3 -1
  18. package/dist/lib/github/v3/createPullRequest.test.js +39 -13
  19. package/dist/lib/github/v3/createStatusComment.js +5 -2
  20. package/dist/lib/github/v3/createStatusComment.test.js +7 -3
  21. package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +20 -1
  22. package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +32 -10
  23. package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js +9 -1
  24. package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +49 -14
  25. package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +15 -5
  26. package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +41 -11
  27. package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -1
  28. package/dist/lib/prompt.test.js +37 -9
  29. package/dist/lib/prompts.js +5 -2
  30. package/dist/lib/setupRepo.js +3 -3
  31. package/dist/lib/setupRepo.test.js +5 -5
  32. package/dist/lib/sourceCommit/getPullRequestStates.d.ts +27 -0
  33. package/dist/lib/sourceCommit/{getExpectedTargetPullRequests.js → getPullRequestStates.js} +62 -27
  34. package/dist/lib/sourceCommit/{getExpectedTargetPullRequests.test.d.ts → getPullRequestStates.test.d.ts} +0 -0
  35. package/dist/lib/sourceCommit/{getExpectedTargetPullRequests.test.js → getPullRequestStates.test.js} +283 -87
  36. package/dist/lib/sourceCommit/parseSourceCommit.d.ts +4 -2
  37. package/dist/lib/sourceCommit/parseSourceCommit.js +20 -5
  38. package/dist/lib/sourceCommit/parseSourceCommit.test.js +78 -25
  39. package/dist/options/ConfigOptions.d.ts +1 -1
  40. package/dist/options/config/config.d.ts +1 -1
  41. package/dist/options/config/readConfigFile.d.ts +1 -1
  42. package/dist/options/options.d.ts +1 -1
  43. package/dist/test/e2e/cli/entrypoint.cli.private.test.js +2 -2
  44. package/dist/test/e2e/cli/repo-with-changing-branchLabelMapping.private.test.d.ts +1 -0
  45. package/dist/test/e2e/cli/repo-with-changing-branchLabelMapping.private.test.js +95 -0
  46. package/dist/test/e2e/module/entrypoint.module.mutation.test.js +11 -4
  47. package/dist/test/handleUnbackportedPullRequests.private.test.js +10 -1
  48. package/dist/utils/filterUnmergedCommits.js +1 -1
  49. package/dist/utils/packageVersion.d.ts +1 -1
  50. package/dist/utils/packageVersion.js +1 -1
  51. package/package.json +13 -13
  52. package/yarn.lock +512 -425
  53. package/dist/lib/sourceCommit/getExpectedTargetPullRequests.d.ts +0 -16
@@ -64,7 +64,12 @@ describe('allFetchers', () => {
64
64
  it('returns correct response for commitByAuthor', async () => {
65
65
  const expectedCommit = {
66
66
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
67
+ suggestedTargetBranches: [],
67
68
  sourceCommit: {
69
+ branchLabelMapping: {
70
+ '^v(\\d+).(\\d+).\\d+$': '$1.$2',
71
+ '^v8.1.0$': 'main',
72
+ },
68
73
  committedDate: '2021-12-20T14:20:16Z',
69
74
  message: '[APM] Add note about synthtrace to APM docs (#121633)',
70
75
  sha: 'd421ddcf6157150596581c7885afa3690cec6339',
@@ -78,9 +83,11 @@ describe('allFetchers', () => {
78
83
  },
79
84
  },
80
85
  sourceBranch: 'main',
81
- expectedTargetPullRequests: [
86
+ pullRequestStates: [
82
87
  {
83
88
  branch: '8.0',
89
+ label: 'v8.0.0',
90
+ isSourceBranch: false,
84
91
  mergeCommit: {
85
92
  message: '[APM] Add note about synthtrace to APM docs (#121633) (#121643)\n\nCo-authored-by: Søren Louv-Jansen <soren.louv@elastic.co>',
86
93
  sha: '842adfdeb5541b059231857522f9009771a46107',
@@ -89,6 +96,18 @@ describe('allFetchers', () => {
89
96
  state: 'MERGED',
90
97
  url: 'https://github.com/elastic/kibana/pull/121643',
91
98
  },
99
+ {
100
+ branch: 'main',
101
+ label: 'v8.1.0',
102
+ isSourceBranch: true,
103
+ mergeCommit: {
104
+ message: '[APM] Add note about synthtrace to APM docs (#121633)',
105
+ sha: 'd421ddcf6157150596581c7885afa3690cec6339',
106
+ },
107
+ number: 121633,
108
+ state: 'MERGED',
109
+ url: 'https://github.com/elastic/kibana/pull/121633',
110
+ },
92
111
  ],
93
112
  };
94
113
  expect(commitByAuthor).toEqual(expectedCommit);
@@ -69,7 +69,13 @@ describe('fetchCommitByPullNumber', () => {
69
69
  };
70
70
  const expectedCommit = {
71
71
  author: { email: 'sorenlouv@gmail.com', name: 'Søren Louv-Jansen' },
72
+ suggestedTargetBranches: [],
72
73
  sourceCommit: {
74
+ branchLabelMapping: {
75
+ '^v(\\d+).(\\d+).\\d+$': '$1.$2',
76
+ '^v7.9.0$': '7.x',
77
+ '^v8.0.0$': 'master',
78
+ },
73
79
  committedDate: '2020-08-15T12:40:19Z',
74
80
  message: 'Add 🍏 emoji (#5)',
75
81
  sha: 'ee8c492334cef1ca077a56addb79a26f79821d2f',
@@ -83,26 +89,42 @@ describe('fetchCommitByPullNumber', () => {
83
89
  },
84
90
  },
85
91
  sourceBranch: 'master',
86
- expectedTargetPullRequests: [
92
+ pullRequestStates: [
87
93
  {
88
- branch: '7.x',
94
+ branch: '7.8',
95
+ isSourceBranch: false,
96
+ label: 'v7.8.0',
97
+ mergeCommit: {
98
+ message: 'Add 🍏 emoji (#5) (#7)',
99
+ sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
100
+ },
101
+ number: 7,
89
102
  state: 'MERGED',
90
- number: 6,
91
- url: 'https://github.com/backport-org/backport-e2e/pull/6',
103
+ url: 'https://github.com/backport-org/backport-e2e/pull/7',
104
+ },
105
+ {
106
+ branch: '7.x',
107
+ isSourceBranch: false,
108
+ label: 'v7.9.0',
92
109
  mergeCommit: {
93
110
  message: 'Add 🍏 emoji (#5) (#6)',
94
111
  sha: '4bcd876d4ceaa73cf437bfc89b74d1a4e704c0a6',
95
112
  },
113
+ number: 6,
114
+ state: 'MERGED',
115
+ url: 'https://github.com/backport-org/backport-e2e/pull/6',
96
116
  },
97
117
  {
98
- branch: '7.8',
99
- state: 'MERGED',
100
- number: 7,
101
- url: 'https://github.com/backport-org/backport-e2e/pull/7',
118
+ branch: 'master',
119
+ isSourceBranch: true,
120
+ label: 'v8.0.0',
102
121
  mergeCommit: {
103
- message: 'Add 🍏 emoji (#5) (#7)',
104
- sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
122
+ message: 'Add 🍏 emoji (#5)',
123
+ sha: 'ee8c492334cef1ca077a56addb79a26f79821d2f',
105
124
  },
125
+ number: 5,
126
+ state: 'MERGED',
127
+ url: 'https://github.com/backport-org/backport-e2e/pull/5',
106
128
  },
107
129
  ],
108
130
  };
@@ -62,7 +62,13 @@ describe('fetchCommitBySha', () => {
62
62
  it('should return single commit with pull request', async () => {
63
63
  const expectedCommit = {
64
64
  author: { email: 'sorenlouv@gmail.com', name: 'Søren Louv-Jansen' },
65
+ suggestedTargetBranches: [],
65
66
  sourceCommit: {
67
+ branchLabelMapping: {
68
+ '^v(\\d+).(\\d+).\\d+$': '$1.$2',
69
+ '^v7.9.0$': '7.x',
70
+ '^v8.0.0$': 'master',
71
+ },
66
72
  committedDate: '2020-07-07T20:40:28Z',
67
73
  message: '[APM] Add API tests (#70740)',
68
74
  sha: 'cb6fbc0e1b406675724181a3e9f59459b5f8f892',
@@ -76,9 +82,11 @@ describe('fetchCommitBySha', () => {
76
82
  },
77
83
  },
78
84
  sourceBranch: 'master',
79
- expectedTargetPullRequests: [
85
+ pullRequestStates: [
80
86
  {
81
87
  branch: '7.x',
88
+ label: 'v7.9.0',
89
+ isSourceBranch: false,
82
90
  state: 'MERGED',
83
91
  number: 71014,
84
92
  url: 'https://github.com/elastic/kibana/pull/71014',
@@ -135,7 +135,7 @@ describe('fetchCommitsByAuthor', () => {
135
135
  ]);
136
136
  });
137
137
  });
138
- describe('expectedTargetPullRequests', () => {
138
+ describe('pullRequestStates', () => {
139
139
  let res;
140
140
  beforeEach(async () => {
141
141
  res = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
@@ -152,9 +152,11 @@ describe('fetchCommitsByAuthor', () => {
152
152
  });
153
153
  it('returns related OPEN PRs', async () => {
154
154
  const commitWithOpenPR = res.find((commit) => commit.sourcePullRequest?.number === 9);
155
- expect(commitWithOpenPR?.expectedTargetPullRequests).toEqual([
155
+ expect(commitWithOpenPR?.pullRequestStates).toEqual([
156
156
  {
157
157
  branch: '7.8',
158
+ label: 'v7.8.0',
159
+ isSourceBranch: false,
158
160
  state: 'OPEN',
159
161
  number: 10,
160
162
  url: 'https://github.com/backport-org/backport-e2e/pull/10',
@@ -163,33 +165,66 @@ describe('fetchCommitsByAuthor', () => {
163
165
  });
164
166
  it('returns related MERGED PRs', async () => {
165
167
  const commitWithMergedPRs = res.find((commit) => commit.sourcePullRequest?.number === 5);
166
- expect(commitWithMergedPRs?.expectedTargetPullRequests).toEqual([
168
+ expect(commitWithMergedPRs?.pullRequestStates).toEqual([
167
169
  {
168
- branch: '7.x',
170
+ branch: '7.8',
171
+ label: 'v7.8.0',
172
+ isSourceBranch: false,
173
+ mergeCommit: {
174
+ message: 'Add 🍏 emoji (#5) (#7)',
175
+ sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
176
+ },
177
+ number: 7,
169
178
  state: 'MERGED',
170
- number: 6,
171
- url: 'https://github.com/backport-org/backport-e2e/pull/6',
179
+ url: 'https://github.com/backport-org/backport-e2e/pull/7',
180
+ },
181
+ {
182
+ branch: '7.x',
183
+ label: 'v7.9.0',
184
+ isSourceBranch: false,
172
185
  mergeCommit: {
173
186
  message: 'Add 🍏 emoji (#5) (#6)',
174
187
  sha: '4bcd876d4ceaa73cf437bfc89b74d1a4e704c0a6',
175
188
  },
189
+ number: 6,
190
+ state: 'MERGED',
191
+ url: 'https://github.com/backport-org/backport-e2e/pull/6',
176
192
  },
177
193
  {
178
- branch: '7.8',
179
- state: 'MERGED',
180
- number: 7,
181
- url: 'https://github.com/backport-org/backport-e2e/pull/7',
194
+ branch: 'master',
195
+ label: 'v8.0.0',
196
+ isSourceBranch: true,
182
197
  mergeCommit: {
183
- message: 'Add 🍏 emoji (#5) (#7)',
184
- sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
198
+ message: 'Add 🍏 emoji (#5)',
199
+ sha: 'ee8c492334cef1ca077a56addb79a26f79821d2f',
185
200
  },
201
+ number: 5,
202
+ state: 'MERGED',
203
+ url: 'https://github.com/backport-org/backport-e2e/pull/5',
186
204
  },
187
205
  ]);
188
206
  });
189
207
  it('returns missing pull requests', async () => {
190
208
  const commitWithoutPRs = res.find((commit) => commit.sourcePullRequest?.number === 8);
191
- expect(commitWithoutPRs?.expectedTargetPullRequests).toEqual([
192
- { branch: '7.x', state: 'NOT_CREATED' },
209
+ expect(commitWithoutPRs?.pullRequestStates).toEqual([
210
+ {
211
+ branch: '7.x',
212
+ label: 'v7.9.0',
213
+ isSourceBranch: false,
214
+ state: 'NOT_CREATED',
215
+ },
216
+ {
217
+ branch: 'master',
218
+ label: 'v8.0.0',
219
+ isSourceBranch: true,
220
+ mergeCommit: {
221
+ message: 'Change Ulysses to Gretha (conflict) (#8)',
222
+ sha: 'b484e161b705b39dbbfc5005e67ca24d05b23c37',
223
+ },
224
+ number: 8,
225
+ state: 'MERGED',
226
+ url: 'https://github.com/backport-org/backport-e2e/pull/8',
227
+ },
193
228
  ]);
194
229
  });
195
230
  });
@@ -47,17 +47,21 @@ describe('fetchCommitsByAuthor', () => {
47
47
  const expectedCommits = [
48
48
  {
49
49
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
50
+ suggestedTargetBranches: [],
50
51
  sourceCommit: {
52
+ branchLabelMapping: undefined,
51
53
  committedDate: '2021-12-24T00:00:00Z',
52
54
  sha: '2e63475c483f7844b0f2833bc57fdee32095bacb',
53
55
  message: 'Add 👻',
54
56
  },
55
- expectedTargetPullRequests: [],
57
+ pullRequestStates: [],
56
58
  sourceBranch: 'source-branch-from-options',
57
59
  },
58
60
  {
59
61
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
62
+ suggestedTargetBranches: [],
60
63
  sourceCommit: {
64
+ branchLabelMapping: undefined,
61
65
  committedDate: '2021-12-23T00:00:00Z',
62
66
  sha: 'f3b618b9421fdecdb36862f907afbdd6344b361d',
63
67
  message: 'Add witch (#85)',
@@ -70,12 +74,14 @@ describe('fetchCommitsByAuthor', () => {
70
74
  message: 'Add witch (#85)',
71
75
  },
72
76
  },
73
- expectedTargetPullRequests: [],
77
+ pullRequestStates: [],
74
78
  sourceBranch: 'master',
75
79
  },
76
80
  {
77
81
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
82
+ suggestedTargetBranches: [],
78
83
  sourceCommit: {
84
+ branchLabelMapping: undefined,
79
85
  committedDate: '2021-12-22T00:00:00Z',
80
86
  sha: '79cf18453ec32a4677009dcbab1c9c8c73fc14fe',
81
87
  message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
@@ -88,7 +94,7 @@ describe('fetchCommitsByAuthor', () => {
88
94
  message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
89
95
  },
90
96
  },
91
- expectedTargetPullRequests: [
97
+ pullRequestStates: [
92
98
  {
93
99
  branch: '6.3',
94
100
  state: 'MERGED',
@@ -104,22 +110,26 @@ describe('fetchCommitsByAuthor', () => {
104
110
  },
105
111
  {
106
112
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
113
+ suggestedTargetBranches: [],
107
114
  sourceCommit: {
115
+ branchLabelMapping: undefined,
108
116
  committedDate: '2021-12-21T00:00:00Z',
109
117
  sha: '3827bbbaf39914eda4f02f6940189844375fd097',
110
118
  message: 'Add backport config',
111
119
  },
112
- expectedTargetPullRequests: [],
120
+ pullRequestStates: [],
113
121
  sourceBranch: 'source-branch-from-options',
114
122
  },
115
123
  {
116
124
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
125
+ suggestedTargetBranches: [],
117
126
  sourceCommit: {
127
+ branchLabelMapping: undefined,
118
128
  committedDate: '2021-12-20T00:00:00Z',
119
129
  sha: '5ea0da550ac191029459289d67f99ad7d310812b',
120
130
  message: 'Initial commit',
121
131
  },
122
- expectedTargetPullRequests: [],
132
+ pullRequestStates: [],
123
133
  sourceBranch: 'source-branch-from-options',
124
134
  },
125
135
  ];
@@ -42,7 +42,13 @@ describe('fetchPullRequestsBySearchQuery', () => {
42
42
  const expectedCommits = [
43
43
  {
44
44
  author: { email: 'sorenlouv@gmail.com', name: 'Søren Louv-Jansen' },
45
+ suggestedTargetBranches: [],
45
46
  sourceCommit: {
47
+ branchLabelMapping: {
48
+ '^v(\\d+).(\\d+).\\d+$': '$1.$2',
49
+ '^v7.9.0$': '7.x',
50
+ '^v8.0.0$': 'master',
51
+ },
46
52
  committedDate: '2020-08-16T21:44:28Z',
47
53
  message: 'Add sheep emoji (#9)',
48
54
  sha: 'eebf165c82a4b718d95c11b3877e365b1949ff28',
@@ -56,9 +62,11 @@ describe('fetchPullRequestsBySearchQuery', () => {
56
62
  },
57
63
  },
58
64
  sourceBranch: 'master',
59
- expectedTargetPullRequests: [
65
+ pullRequestStates: [
60
66
  {
61
67
  branch: '7.8',
68
+ label: 'v7.8.0',
69
+ isSourceBranch: false,
62
70
  state: 'OPEN',
63
71
  number: 10,
64
72
  url: 'https://github.com/backport-org/backport-e2e/pull/10',
@@ -67,7 +75,13 @@ describe('fetchPullRequestsBySearchQuery', () => {
67
75
  },
68
76
  {
69
77
  author: { email: 'sorenlouv@gmail.com', name: 'Søren Louv-Jansen' },
78
+ suggestedTargetBranches: [],
70
79
  sourceCommit: {
80
+ branchLabelMapping: {
81
+ '^v(\\d+).(\\d+).\\d+$': '$1.$2',
82
+ '^v7.9.0$': '7.x',
83
+ '^v8.0.0$': 'master',
84
+ },
71
85
  committedDate: '2020-08-15T12:40:19Z',
72
86
  message: 'Add 🍏 emoji (#5)',
73
87
  sha: 'ee8c492334cef1ca077a56addb79a26f79821d2f',
@@ -81,26 +95,42 @@ describe('fetchPullRequestsBySearchQuery', () => {
81
95
  },
82
96
  },
83
97
  sourceBranch: 'master',
84
- expectedTargetPullRequests: [
98
+ pullRequestStates: [
85
99
  {
86
- branch: '7.x',
100
+ branch: '7.8',
101
+ isSourceBranch: false,
102
+ label: 'v7.8.0',
103
+ mergeCommit: {
104
+ message: 'Add 🍏 emoji (#5) (#7)',
105
+ sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
106
+ },
107
+ number: 7,
87
108
  state: 'MERGED',
88
- number: 6,
89
- url: 'https://github.com/backport-org/backport-e2e/pull/6',
109
+ url: 'https://github.com/backport-org/backport-e2e/pull/7',
110
+ },
111
+ {
112
+ branch: '7.x',
113
+ isSourceBranch: false,
114
+ label: 'v7.9.0',
90
115
  mergeCommit: {
91
116
  message: 'Add 🍏 emoji (#5) (#6)',
92
117
  sha: '4bcd876d4ceaa73cf437bfc89b74d1a4e704c0a6',
93
118
  },
119
+ number: 6,
120
+ state: 'MERGED',
121
+ url: 'https://github.com/backport-org/backport-e2e/pull/6',
94
122
  },
95
123
  {
96
- branch: '7.8',
97
- state: 'MERGED',
98
- number: 7,
99
- url: 'https://github.com/backport-org/backport-e2e/pull/7',
124
+ branch: 'master',
125
+ isSourceBranch: true,
126
+ label: 'v8.0.0',
100
127
  mergeCommit: {
101
- message: 'Add 🍏 emoji (#5) (#7)',
102
- sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
128
+ message: 'Add 🍏 emoji (#5)',
129
+ sha: 'ee8c492334cef1ca077a56addb79a26f79821d2f',
103
130
  },
131
+ number: 5,
132
+ state: 'MERGED',
133
+ url: 'https://github.com/backport-org/backport-e2e/pull/5',
104
134
  },
105
135
  ],
106
136
  },
@@ -48,7 +48,7 @@ export declare function getOptionsFromGithub(options: {
48
48
  publishStatusCommentOnAbort?: boolean | undefined;
49
49
  publishStatusCommentOnFailure?: boolean | undefined;
50
50
  publishStatusCommentOnSuccess?: boolean | undefined;
51
- pullNumber?: number | undefined;
51
+ pullNumber?: number | number[] | undefined;
52
52
  repoForkOwner?: string | undefined;
53
53
  repoName?: string | undefined;
54
54
  repoOwner?: string | undefined;
@@ -7,12 +7,14 @@ const strip_ansi_1 = __importDefault(require("strip-ansi"));
7
7
  const prompts_1 = require("./prompts");
8
8
  describe('prompt', () => {
9
9
  describe('getChoicesForCommitPrompt', () => {
10
- it('should display status badges via `expectedTargetPullRequests`', () => {
10
+ it('should display status badges via `pullRequestStates`', () => {
11
11
  const commits = [
12
12
  {
13
13
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
14
14
  sourceBranch: 'master',
15
+ suggestedTargetBranches: [],
15
16
  sourceCommit: {
17
+ branchLabelMapping: {},
16
18
  committedDate: '1',
17
19
  sha: 'ae9d51b7fe3ee6f30d0d196c782e0dcabb7ac5ff',
18
20
  message: '[APM] Remove log-log descriptions from correlation charts (#119700)',
@@ -25,10 +27,28 @@ describe('prompt', () => {
25
27
  message: '[APM] Remove log-log descriptions from correlation charts (#119700)',
26
28
  },
27
29
  },
28
- expectedTargetPullRequests: [
29
- { number: 120178, branch: '8.0', state: 'MERGED' },
30
- { number: 120179, branch: '7.16', state: 'MERGED' },
31
- { number: 120179, branch: '7.15', state: 'NOT_CREATED' },
30
+ pullRequestStates: [
31
+ {
32
+ number: 120178,
33
+ branch: '8.0',
34
+ label: '',
35
+ isSourceBranch: false,
36
+ state: 'MERGED',
37
+ },
38
+ {
39
+ number: 120179,
40
+ branch: '7.16',
41
+ state: 'MERGED',
42
+ label: '',
43
+ isSourceBranch: false,
44
+ },
45
+ {
46
+ number: 120179,
47
+ branch: '7.15',
48
+ state: 'NOT_CREATED',
49
+ label: '',
50
+ isSourceBranch: false,
51
+ },
32
52
  ],
33
53
  },
34
54
  ];
@@ -45,7 +65,9 @@ describe('prompt', () => {
45
65
  {
46
66
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
47
67
  sourceBranch: 'master',
68
+ suggestedTargetBranches: [],
48
69
  sourceCommit: {
70
+ branchLabelMapping: {},
49
71
  committedDate: '',
50
72
  sha: 'b1b491959dab47aeb83c88ee2accb2db46d23793',
51
73
  message: '[APM] Prefer service.name for logs correlation (#120694)',
@@ -58,12 +80,14 @@ describe('prompt', () => {
58
80
  message: '[APM] Prefer service.name for logs correlation (#120694)',
59
81
  },
60
82
  },
61
- expectedTargetPullRequests: [],
83
+ pullRequestStates: [],
62
84
  },
63
85
  {
64
86
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
65
87
  sourceBranch: 'master',
88
+ suggestedTargetBranches: [],
66
89
  sourceCommit: {
90
+ branchLabelMapping: {},
67
91
  committedDate: '',
68
92
  sha: 'b1bb4a93959f19a653b9cfb207a5c6acb6559482',
69
93
  message: '[APM] Disable telemetry in agent config endpoint (#120106)',
@@ -76,12 +100,14 @@ describe('prompt', () => {
76
100
  message: '[APM] Disable telemetry in agent config endpoint (#120106)',
77
101
  },
78
102
  },
79
- expectedTargetPullRequests: [],
103
+ pullRequestStates: [],
80
104
  },
81
105
  {
82
106
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
83
107
  sourceBranch: 'master',
108
+ suggestedTargetBranches: [],
84
109
  sourceCommit: {
110
+ branchLabelMapping: {},
85
111
  committedDate: '',
86
112
  sha: '434f6e6a88faf24dc1ea41f9f726db78e46355a7',
87
113
  message: '[APM] Remove index_pattern.json and add custom field formatters (#119915)',
@@ -94,12 +120,14 @@ describe('prompt', () => {
94
120
  message: '[APM] Remove index_pattern.json and add custom field formatters (#119915)',
95
121
  },
96
122
  },
97
- expectedTargetPullRequests: [],
123
+ pullRequestStates: [],
98
124
  },
99
125
  {
100
126
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
101
127
  sourceBranch: 'master',
128
+ suggestedTargetBranches: [],
102
129
  sourceCommit: {
130
+ branchLabelMapping: {},
103
131
  committedDate: '',
104
132
  sha: 'ae9d51b7fe3ee6f30d0d196c782e0dcabb7ac5ff',
105
133
  message: '[APM] Remove log-log descriptions from correlation charts (#119700)',
@@ -112,7 +140,7 @@ describe('prompt', () => {
112
140
  message: '[APM] Remove log-log descriptions from correlation charts (#119700)',
113
141
  },
114
142
  },
115
- expectedTargetPullRequests: [],
143
+ pullRequestStates: [],
116
144
  },
117
145
  ];
118
146
  const choices = (0, prompts_1.getChoicesForCommitPrompt)(commits, false).map(({ name, short }) => ({ name: (0, strip_ansi_1.default)(name), short }));
@@ -44,7 +44,9 @@ function getPrLink(number, url) {
44
44
  return url ? `(${(0, terminal_link_1.default)(`#${number}`, url)})` : '';
45
45
  }
46
46
  function getDetailedPullStatus(c) {
47
- const items = c.expectedTargetPullRequests.map((pr) => {
47
+ const items = c.pullRequestStates
48
+ .filter(({ isSourceBranch }) => !isSourceBranch)
49
+ .map((pr) => {
48
50
  const prLink = getPrLink(pr.number, pr.url);
49
51
  return ` └ ${getPrStateIcon(pr.state)} ${pr.branch} ${prLink} ${getPrStateText(pr.state)}`;
50
52
  });
@@ -54,7 +56,8 @@ function getDetailedPullStatus(c) {
54
56
  return `${list}\n`;
55
57
  }
56
58
  function getSimplePullStatus(c) {
57
- return c.expectedTargetPullRequests
59
+ return c.pullRequestStates
60
+ .filter(({ isSourceBranch }) => !isSourceBranch)
58
61
  .map(({ state, branch }) => {
59
62
  if (state === 'MERGED') {
60
63
  return chalk_1.default.green(branch);
@@ -9,11 +9,11 @@ const ora_1 = require("./ora");
9
9
  async function setupRepo(options) {
10
10
  const repoPath = (0, env_1.getRepoPath)(options);
11
11
  const isAlreadyCloned = await getIsRepoCloned(options);
12
- if (options.cwd.includes(repoPath)) {
13
- throw new BackportError_1.BackportError(`Refusing to clone repo into "${repoPath}" when current working directory is "${options.cwd}". Please change backport directory via \`--dir\` option or run backport from another location`);
14
- }
15
12
  // clone repo if folder does not already exists
16
13
  if (!isAlreadyCloned) {
14
+ if (options.cwd.includes(repoPath)) {
15
+ throw new BackportError_1.BackportError(`Refusing to clone repo into "${repoPath}" when current working directory is "${options.cwd}". Please change backport directory via \`--dir\` option or run backport from another location`);
16
+ }
17
17
  const spinner = (0, ora_1.ora)(options.interactive).start();
18
18
  try {
19
19
  const localRepoPath = await (0, git_1.getLocalSourceRepoPath)(options);
@@ -47,7 +47,7 @@ describe('setupRepo', () => {
47
47
  it('should delete repo', async () => {
48
48
  expect.assertions(2);
49
49
  jest
50
- .spyOn(childProcess, 'spawnOriginal')
50
+ .spyOn(childProcess, 'spawnStream')
51
51
  .mockImplementation((cmd, cmdArgs) => {
52
52
  if (cmdArgs.includes('clone')) {
53
53
  throw new Error('Simulated git clone failure');
@@ -74,7 +74,7 @@ describe('setupRepo', () => {
74
74
  .spyOn(gitModule, 'getLocalSourceRepoPath')
75
75
  .mockResolvedValue(undefined);
76
76
  jest
77
- .spyOn(childProcess, 'spawnOriginal')
77
+ .spyOn(childProcess, 'spawnStream')
78
78
  //@ts-expect-error
79
79
  .mockImplementation(() => {
80
80
  return {
@@ -194,7 +194,7 @@ describe('setupRepo', () => {
194
194
  });
195
195
  function mockGitClone() {
196
196
  jest
197
- .spyOn(childProcess, 'spawnOriginal')
197
+ .spyOn(childProcess, 'spawnStream')
198
198
  //@ts-expect-error
199
199
  .mockImplementation((cmd, cmdArgs) => {
200
200
  if (cmdArgs.includes('clone')) {
@@ -227,7 +227,7 @@ describe('setupRepo', () => {
227
227
  });
228
228
  it('should clone it from github.com', async () => {
229
229
  expect(spinnerSuccessSpy).toHaveBeenCalledWith('100% Cloning repository from github.com (one-time operation)');
230
- expect(childProcess.spawnOriginal).toHaveBeenCalledWith('git', [
230
+ expect(childProcess.spawnStream).toHaveBeenCalledWith('git', [
231
231
  'clone',
232
232
  'https://x-access-token:myAccessToken@github.com/elastic/kibana.git',
233
233
  '/myHomeDir/.backport/repositories/elastic/kibana',
@@ -256,7 +256,7 @@ describe('setupRepo', () => {
256
256
  });
257
257
  it('should clone it from local folder', async () => {
258
258
  expect(spinnerSuccessSpy).toHaveBeenCalledWith('100% Cloning repository from /path/to/source/repo (one-time operation)');
259
- expect(childProcess.spawnOriginal).toHaveBeenCalledWith('git', [
259
+ expect(childProcess.spawnStream).toHaveBeenCalledWith('git', [
260
260
  'clone',
261
261
  '/path/to/source/repo',
262
262
  '/myHomeDir/.backport/repositories/elastic/kibana',
@@ -0,0 +1,27 @@
1
+ import { ValidConfigOptions } from '../../options/options';
2
+ import { SourceCommitWithTargetPullRequest } from './parseSourceCommit';
3
+ export declare type PullRequestState = 'OPEN' | 'CLOSED' | 'MERGED' | 'NOT_CREATED';
4
+ declare type CreatedPullRequest = {
5
+ url: string;
6
+ number: number;
7
+ branch: string;
8
+ state: PullRequestState;
9
+ mergeCommit?: {
10
+ sha: string;
11
+ message: string;
12
+ };
13
+ };
14
+ declare type TargetBranchWithLabel = {
15
+ branch: string;
16
+ label: string;
17
+ isSourceBranch: boolean;
18
+ };
19
+ export declare type TargetPullRequest = (CreatedPullRequest & Partial<TargetBranchWithLabel>) | ((TargetBranchWithLabel & Partial<CreatedPullRequest>) & {
20
+ state: PullRequestState;
21
+ });
22
+ export declare function getSourceCommitBranchLabelMapping(sourceCommit: SourceCommitWithTargetPullRequest): ValidConfigOptions['branchLabelMapping'];
23
+ export declare function getPullRequestStates({ sourceCommit, branchLabelMapping, }: {
24
+ sourceCommit: SourceCommitWithTargetPullRequest;
25
+ branchLabelMapping: ValidConfigOptions['branchLabelMapping'];
26
+ }): TargetPullRequest[];
27
+ export {};