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
@@ -34,8 +34,8 @@ describe('getCommitsWithoutBackports', () => {
34
34
  afterEach(() => {
35
35
  jest.restoreAllMocks();
36
36
  });
37
- describe('expectedTargetPullRequests', () => {
38
- function setupExpectedPullRequests({ expectedTargetPullRequests, }) {
37
+ describe('pullRequestStates', () => {
38
+ function setupExpectedPullRequests({ pullRequestStates, }) {
39
39
  // simulate 1 unbackported commit
40
40
  jest
41
41
  .spyOn(fetchCommitsByAuthorModule, 'fetchCommitsByAuthor')
@@ -45,7 +45,9 @@ describe('getCommitsWithoutBackports', () => {
45
45
  email: 'soren.louv@elastic.co',
46
46
  name: 'Søren Louv-Jansen',
47
47
  },
48
+ suggestedTargetBranches: [],
48
49
  sourceCommit: {
50
+ branchLabelMapping: {},
49
51
  committedDate: '10',
50
52
  message: 'First commit (#1)',
51
53
  sha: 'xyz',
@@ -58,7 +60,7 @@ describe('getCommitsWithoutBackports', () => {
58
60
  sha: 'xyz',
59
61
  },
60
62
  },
61
- expectedTargetPullRequests,
63
+ pullRequestStates,
62
64
  sourceBranch: 'main',
63
65
  },
64
66
  ]);
@@ -68,12 +70,14 @@ describe('getCommitsWithoutBackports', () => {
68
70
  options: {},
69
71
  commit: {
70
72
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
73
+ suggestedTargetBranches: [],
71
74
  sourceCommit: {
75
+ branchLabelMapping: {},
72
76
  committedDate: '100',
73
77
  message: 'Second commit (#2)',
74
78
  sha: 'abc',
75
79
  },
76
- expectedTargetPullRequests: [],
80
+ pullRequestStates: [],
77
81
  sourceBranch: 'main',
78
82
  },
79
83
  targetBranch: '7.x',
@@ -82,13 +86,13 @@ describe('getCommitsWithoutBackports', () => {
82
86
  }
83
87
  it('should not unbackported commits if no backports were expected', async () => {
84
88
  const commitsWithoutBackports = await setupExpectedPullRequests({
85
- expectedTargetPullRequests: [],
89
+ pullRequestStates: [],
86
90
  });
87
91
  expect(commitsWithoutBackports.length).toEqual(0);
88
92
  });
89
93
  it('should display as missing if a backport is CLOSED', async () => {
90
94
  const commitsWithoutBackports = await setupExpectedPullRequests({
91
- expectedTargetPullRequests: [
95
+ pullRequestStates: [
92
96
  {
93
97
  state: 'CLOSED',
94
98
  branch: '7.x',
@@ -101,13 +105,20 @@ describe('getCommitsWithoutBackports', () => {
101
105
  });
102
106
  it('should display as missing if a backport is NOT_CREATED', async () => {
103
107
  const commitsWithoutBackports = await setupExpectedPullRequests({
104
- expectedTargetPullRequests: [{ state: 'NOT_CREATED', branch: '7.x' }],
108
+ pullRequestStates: [
109
+ {
110
+ state: 'NOT_CREATED',
111
+ branch: '7.x',
112
+ label: 'v7.0.0',
113
+ isSourceBranch: false,
114
+ },
115
+ ],
105
116
  });
106
117
  expect((0, strip_ansi_1.default)(commitsWithoutBackports[0].formatted)).toEqual(' - First commit (#1) (backport missing)\n https://www.github.com/foo/bar/pull/123');
107
118
  });
108
119
  it('should display as pending if a backport is OPEN', async () => {
109
120
  const commitsWithoutBackports = await setupExpectedPullRequests({
110
- expectedTargetPullRequests: [
121
+ pullRequestStates: [
111
122
  {
112
123
  state: 'OPEN',
113
124
  branch: '7.x',
@@ -120,7 +131,7 @@ describe('getCommitsWithoutBackports', () => {
120
131
  });
121
132
  it('should not display commit as unbackported if a backport was MERGED', async () => {
122
133
  const commitsWithoutBackports = await setupExpectedPullRequests({
123
- expectedTargetPullRequests: [
134
+ pullRequestStates: [
124
135
  {
125
136
  state: 'MERGED',
126
137
  branch: '7.x',
@@ -143,7 +154,9 @@ describe('getCommitsWithoutBackports', () => {
143
154
  email: 'soren.louv@elastic.co',
144
155
  name: 'Søren Louv-Jansen',
145
156
  },
157
+ suggestedTargetBranches: [],
146
158
  sourceCommit: {
159
+ branchLabelMapping: {},
147
160
  committedDate: offendingCommitDate,
148
161
  message: 'First commit (#1)',
149
162
  sha: 'xyz',
@@ -157,7 +170,7 @@ describe('getCommitsWithoutBackports', () => {
157
170
  },
158
171
  },
159
172
  sourceBranch: 'main',
160
- expectedTargetPullRequests: [
173
+ pullRequestStates: [
161
174
  {
162
175
  state: 'OPEN',
163
176
  branch: '7.x',
@@ -173,7 +186,9 @@ describe('getCommitsWithoutBackports', () => {
173
186
  options: {},
174
187
  commit: {
175
188
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
189
+ suggestedTargetBranches: [],
176
190
  sourceCommit: {
191
+ branchLabelMapping: {},
177
192
  committedDate: currentCommitDate,
178
193
  message: 'Second commit (#2)',
179
194
  sha: 'abc',
@@ -187,7 +202,7 @@ describe('getCommitsWithoutBackports', () => {
187
202
  },
188
203
  },
189
204
  sourceBranch: 'main',
190
- expectedTargetPullRequests: [],
205
+ pullRequestStates: [],
191
206
  },
192
207
  targetBranch: '7.x',
193
208
  conflictingFiles: ['/foo/bar/baz.ts'],
@@ -219,7 +234,9 @@ describe('getCommitsWithoutBackports', () => {
219
234
  email: 'soren.louv@elastic.co',
220
235
  name: 'Søren Louv-Jansen',
221
236
  },
237
+ suggestedTargetBranches: [],
222
238
  sourceCommit: {
239
+ branchLabelMapping: {},
223
240
  committedDate: '10',
224
241
  message: 'First commit (#1)',
225
242
  sha: 'xyz',
@@ -233,7 +250,7 @@ describe('getCommitsWithoutBackports', () => {
233
250
  },
234
251
  },
235
252
  sourceBranch: 'main',
236
- expectedTargetPullRequests: [
253
+ pullRequestStates: [
237
254
  {
238
255
  branch: offendingCommitTargetBranch,
239
256
  state: 'OPEN',
@@ -250,7 +267,9 @@ describe('getCommitsWithoutBackports', () => {
250
267
  // commit that is being backported
251
268
  commit: {
252
269
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
270
+ suggestedTargetBranches: [],
253
271
  sourceCommit: {
272
+ branchLabelMapping: {},
254
273
  committedDate: '100',
255
274
  message: 'Second commit (#2)',
256
275
  sha: 'abc',
@@ -263,7 +282,7 @@ describe('getCommitsWithoutBackports', () => {
263
282
  sha: 'abc',
264
283
  },
265
284
  },
266
- expectedTargetPullRequests: [],
285
+ pullRequestStates: [],
267
286
  sourceBranch: 'main',
268
287
  },
269
288
  targetBranch: currentCommitTargetBranch,
@@ -295,12 +314,14 @@ describe('getCommitsWithoutBackports', () => {
295
314
  email: 'soren.louv@elastic.co',
296
315
  name: 'Søren Louv-Jansen',
297
316
  },
317
+ suggestedTargetBranches: [],
298
318
  sourceCommit: {
319
+ branchLabelMapping: {},
299
320
  committedDate: '10',
300
321
  sha: 'xyz',
301
322
  message: 'First commit (#1)',
302
323
  },
303
- expectedTargetPullRequests: [],
324
+ pullRequestStates: [],
304
325
  sourceBranch: 'main',
305
326
  },
306
327
  ]);
@@ -310,7 +331,9 @@ describe('getCommitsWithoutBackports', () => {
310
331
  options: {},
311
332
  commit: {
312
333
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
334
+ suggestedTargetBranches: [],
313
335
  sourceCommit: {
336
+ branchLabelMapping: {},
314
337
  committedDate: '100',
315
338
  message: 'Second commit (#2)',
316
339
  sha: 'abc',
@@ -323,7 +346,7 @@ describe('getCommitsWithoutBackports', () => {
323
346
  sha: 'abc',
324
347
  },
325
348
  },
326
- expectedTargetPullRequests: [],
349
+ pullRequestStates: [],
327
350
  sourceBranch: 'main',
328
351
  },
329
352
  targetBranch: '7.x',
@@ -2,4 +2,4 @@ import { TargetBranchChoice } from '../options/ConfigOptions';
2
2
  import { ValidConfigOptions } from '../options/options';
3
3
  import { Commit } from './sourceCommit/parseSourceCommit';
4
4
  export declare function getTargetBranches(options: ValidConfigOptions, commits: Commit[]): Promise<string[]>;
5
- export declare function getTargetBranchChoices(options: ValidConfigOptions, missingTargetBranches: string[], sourceBranch: string): TargetBranchChoice[];
5
+ export declare function getTargetBranchChoices(options: ValidConfigOptions, suggestedTargetBranches: string[], sourceBranch: string): TargetBranchChoice[];
@@ -10,22 +10,18 @@ async function getTargetBranches(options, commits) {
10
10
  return options.targetBranches;
11
11
  }
12
12
  // target branches from the first commit
13
- const missingTargetBranches = commits.length === 1
14
- ? commits[0].expectedTargetPullRequests
15
- .filter((pr) => pr.state === 'NOT_CREATED' || pr.state === 'CLOSED')
16
- .map((pr) => pr.branch)
17
- : [];
13
+ const suggestedTargetBranches = commits.length === 1 ? commits[0].suggestedTargetBranches : [];
18
14
  // require target branches to be specified when when in non-interactive mode
19
15
  if (!options.interactive) {
20
- if ((0, lodash_1.isEmpty)(missingTargetBranches)) {
16
+ if ((0, lodash_1.isEmpty)(suggestedTargetBranches)) {
21
17
  throw new BackportError_1.BackportError({ code: 'no-branches-exception' });
22
18
  }
23
- return missingTargetBranches;
19
+ return suggestedTargetBranches;
24
20
  }
25
21
  // sourceBranch should be the same for all commits, so picking `sourceBranch` from the first commit should be fine 🤞
26
22
  // this is specifically needed when backporting a PR like `backport --pr 123` and the source PR was merged to a non-default (aka non-master) branch.
27
23
  const { sourceBranch } = commits[0];
28
- const targetBranchChoices = getTargetBranchChoices(options, missingTargetBranches, sourceBranch);
24
+ const targetBranchChoices = getTargetBranchChoices(options, suggestedTargetBranches, sourceBranch);
29
25
  // render prmompt for selecting target branches
30
26
  return (0, prompts_1.promptForTargetBranches)({
31
27
  targetBranchChoices,
@@ -33,7 +29,7 @@ async function getTargetBranches(options, commits) {
33
29
  });
34
30
  }
35
31
  exports.getTargetBranches = getTargetBranches;
36
- function getTargetBranchChoices(options, missingTargetBranches, sourceBranch) {
32
+ function getTargetBranchChoices(options, suggestedTargetBranches, sourceBranch) {
37
33
  // exclude sourceBranch from targetBranchChoices
38
34
  const targetBranchesChoices = getTargetBranchChoicesAsObject(options.targetBranchChoices).filter((choice) => choice.name !== sourceBranch);
39
35
  if ((0, lodash_1.isEmpty)(targetBranchesChoices)) {
@@ -44,7 +40,7 @@ function getTargetBranchChoices(options, missingTargetBranches, sourceBranch) {
44
40
  }
45
41
  // select missing target branches (based on pull request labels)
46
42
  return targetBranchesChoices.map((choice) => {
47
- const isChecked = missingTargetBranches.includes(choice.name);
43
+ const isChecked = suggestedTargetBranches.includes(choice.name);
48
44
  return { ...choice, checked: isChecked };
49
45
  });
50
46
  }
@@ -47,6 +47,7 @@ describe('getTargetBranches', () => {
47
47
  {
48
48
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
49
49
  sourceCommit: {
50
+ branchLabelMapping: {},
50
51
  committedDate: 'aaa',
51
52
  message: 'hey',
52
53
  sha: 'abcd',
@@ -60,7 +61,8 @@ describe('getTargetBranches', () => {
60
61
  },
61
62
  },
62
63
  sourceBranch: '7.x',
63
- expectedTargetPullRequests: [],
64
+ suggestedTargetBranches: [],
65
+ pullRequestStates: [],
64
66
  },
65
67
  ];
66
68
  branches = await (0, getTargetBranches_1.getTargetBranches)(options, commits);
@@ -99,7 +101,6 @@ describe('getTargetBranches', () => {
99
101
  const commits = [];
100
102
  await expect(() => {
101
103
  return (0, getTargetBranches_1.getTargetBranches)({
102
- expectedTargetPullRequests: [],
103
104
  interactive: false,
104
105
  }, commits);
105
106
  }).rejects.toThrowError('There are no branches to backport to. Aborting.');
@@ -107,7 +108,8 @@ describe('getTargetBranches', () => {
107
108
  it('should return missing backports', async () => {
108
109
  const commits = [
109
110
  {
110
- expectedTargetPullRequests: [
111
+ suggestedTargetBranches: ['7.x'],
112
+ pullRequestStates: [
111
113
  { branch: '7.2', state: 'MERGED' },
112
114
  { branch: '7.1', state: 'OPEN' },
113
115
  { branch: '7.x', state: 'NOT_CREATED' },
@@ -118,7 +120,7 @@ describe('getTargetBranches', () => {
118
120
  expect(targetBranches).toEqual(['7.x']);
119
121
  });
120
122
  });
121
- describe('when `expectedTargetPullRequests` is missing a backport to 7.x', () => {
123
+ describe('when `pullRequestStates` is missing a backport to 7.x', () => {
122
124
  let targetBranchChoices;
123
125
  beforeEach(async () => {
124
126
  const options = {
@@ -139,6 +141,7 @@ describe('getTargetBranches', () => {
139
141
  {
140
142
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
141
143
  sourceCommit: {
144
+ branchLabelMapping: {},
142
145
  committedDate: 'bbb',
143
146
  message: '[backport] Bump to 5.1.3 (#62286)',
144
147
  sha: 'my-sha',
@@ -152,7 +155,8 @@ describe('getTargetBranches', () => {
152
155
  },
153
156
  },
154
157
  sourceBranch: 'master',
155
- expectedTargetPullRequests: [{ branch: '7.x', state: 'NOT_CREATED' }],
158
+ suggestedTargetBranches: ['7.x'],
159
+ pullRequestStates: [],
156
160
  },
157
161
  ];
158
162
  await (0, getTargetBranches_1.getTargetBranches)(options, commits);
package/dist/lib/git.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ValidConfigOptions } from '../options/options';
2
2
  import { CommitAuthor } from './author';
3
- import { ExpectedTargetPullRequest } from './sourceCommit/getExpectedTargetPullRequests';
3
+ import { TargetPullRequest } from './sourceCommit/getPullRequestStates';
4
4
  import { Commit } from './sourceCommit/parseSourceCommit';
5
5
  export declare function getRemoteUrl({ repoName, accessToken, gitHostname }: ValidConfigOptions, repoOwner: string): string;
6
6
  export declare function cloneRepo({ sourcePath, targetPath }: {
@@ -32,7 +32,7 @@ export declare function getShasInMergeCommit(options: ValidConfigOptions, sha: s
32
32
  export declare function cherrypick({ options, sha, mergedTargetPullRequest, commitAuthor, }: {
33
33
  options: ValidConfigOptions;
34
34
  sha: string;
35
- mergedTargetPullRequest?: ExpectedTargetPullRequest;
35
+ mergedTargetPullRequest?: TargetPullRequest;
36
36
  commitAuthor: CommitAuthor;
37
37
  }): Promise<{
38
38
  conflictingFiles: {
package/dist/lib/git.js CHANGED
@@ -17,7 +17,7 @@ exports.getRemoteUrl = getRemoteUrl;
17
17
  async function cloneRepo({ sourcePath, targetPath }, onProgress) {
18
18
  logger_1.logger.info(`Cloning repo from ${sourcePath} to ${targetPath}`);
19
19
  return new Promise((resolve, reject) => {
20
- const subprocess = (0, child_process_promisified_1.spawnOriginal)('git', [
20
+ const subprocess = (0, child_process_promisified_1.spawnStream)('git', [
21
21
  'clone',
22
22
  sourcePath,
23
23
  targetPath,
@@ -39,7 +39,7 @@ jest.unmock('del');
39
39
  jest.unmock('make-dir');
40
40
  const commitAuthor = { name: 'Soren L', email: 'soren@mail.dk' };
41
41
  const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
42
- describe('git.integration', () => {
42
+ describe('git.private', () => {
43
43
  describe('getIsCommitInBranch', () => {
44
44
  let firstSha;
45
45
  let secondSha;
@@ -80,6 +80,23 @@ describe('git.integration', () => {
80
80
  expect(isSecondCommitInBranch).toEqual(false);
81
81
  });
82
82
  });
83
+ describe('deleteRemote', () => {
84
+ const cwd = (0, sandbox_1.getSandboxPath)({
85
+ filename: __filename,
86
+ specname: 'deleteRemote',
87
+ });
88
+ it('should handle when deleting a remote that does not exist', async () => {
89
+ const options = {
90
+ repoName: 'kibana',
91
+ repoOwner: 'elastic',
92
+ dir: cwd,
93
+ };
94
+ await (0, sandbox_1.resetSandbox)(cwd);
95
+ await gitInit(cwd);
96
+ const res = await (0, git_1.deleteRemote)(options, 'my-remote-foo');
97
+ expect(res).toBe(undefined);
98
+ });
99
+ });
83
100
  describe('getGitConfig', () => {
84
101
  const cwd = (0, sandbox_1.getSandboxPath)({
85
102
  filename: __filename,
@@ -477,13 +477,15 @@ describe('commitChanges', () => {
477
477
  };
478
478
  const commit = {
479
479
  author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
480
+ suggestedTargetBranches: [],
480
481
  sourceCommit: {
482
+ branchLabelMapping: {},
481
483
  message: 'The original commit message',
482
484
  committedDate: '2020',
483
485
  sha: 'abc',
484
486
  },
485
487
  sourceBranch: 'master',
486
- expectedTargetPullRequests: [],
488
+ pullRequestStates: [],
487
489
  };
488
490
  it('should return when changes committed successfully', async () => {
489
491
  jest
@@ -19,12 +19,14 @@ describe('getPullRequestBody', () => {
19
19
  message: 'My commit message (#55)',
20
20
  },
21
21
  },
22
+ suggestedTargetBranches: [],
22
23
  sourceCommit: {
24
+ branchLabelMapping: {},
23
25
  committedDate: '2020',
24
26
  sha: 'abcdefghi',
25
27
  message: 'My commit message (#55)',
26
28
  },
27
- expectedTargetPullRequests: [],
29
+ pullRequestStates: [],
28
30
  sourceBranch: 'master',
29
31
  },
30
32
  ],
@@ -50,13 +52,15 @@ describe('getPullRequestBody', () => {
50
52
  email: 'soren.louv@elastic.co',
51
53
  name: 'Søren Louv-Jansen',
52
54
  },
55
+ suggestedTargetBranches: [],
53
56
  sourceCommit: {
57
+ branchLabelMapping: {},
54
58
  committedDate: '',
55
59
  sha: 'abcdefghijklmw',
56
60
  message: 'My commit message',
57
61
  },
58
62
  sourceBranch: 'main',
59
- expectedTargetPullRequests: [],
63
+ pullRequestStates: [],
60
64
  },
61
65
  ],
62
66
  targetBranch: '7.x',
@@ -89,26 +93,30 @@ describe('getPullRequestBody', () => {
89
93
  message: 'My commit message (#55)',
90
94
  },
91
95
  },
96
+ suggestedTargetBranches: [],
92
97
  sourceCommit: {
98
+ branchLabelMapping: {},
93
99
  committedDate: '',
94
100
  sha: 'abcdefghijklm',
95
101
  message: 'My commit message (#55)',
96
102
  },
97
103
  sourceBranch: 'main',
98
- expectedTargetPullRequests: [],
104
+ pullRequestStates: [],
99
105
  },
100
106
  {
101
107
  author: {
102
108
  email: 'soren.louv@elastic.co',
103
109
  name: 'Søren Louv-Jansen',
104
110
  },
111
+ suggestedTargetBranches: [],
105
112
  sourceCommit: {
113
+ branchLabelMapping: {},
106
114
  committedDate: '',
107
115
  sha: 'qwertyuiop',
108
116
  message: 'Another commit message',
109
117
  },
110
118
  sourceBranch: 'main',
111
- expectedTargetPullRequests: [],
119
+ pullRequestStates: [],
112
120
  },
113
121
  ],
114
122
  targetBranch: '7.x',
@@ -130,7 +138,9 @@ describe('getPullRequestBody', () => {
130
138
  options: {},
131
139
  commits: [
132
140
  {
141
+ suggestedTargetBranches: [],
133
142
  sourceCommit: {
143
+ branchLabelMapping: {},
134
144
  committedDate: '2022-02-07T23:53:14Z',
135
145
  message: 'Merge strategy: Second commit',
136
146
  sha: 'e8df5eaa4db7b94474b48e2320b02d33a830d9fb',
@@ -148,10 +158,12 @@ describe('getPullRequestBody', () => {
148
158
  },
149
159
  },
150
160
  sourceBranch: 'main',
151
- expectedTargetPullRequests: [],
161
+ pullRequestStates: [],
152
162
  },
153
163
  {
164
+ suggestedTargetBranches: [],
154
165
  sourceCommit: {
166
+ branchLabelMapping: {},
155
167
  committedDate: '2022-02-07T23:51:59Z',
156
168
  message: 'Merge strategy: First commit',
157
169
  sha: '5411b1c1144093e422220008f23f2c2b909ed113',
@@ -169,7 +181,7 @@ describe('getPullRequestBody', () => {
169
181
  },
170
182
  },
171
183
  sourceBranch: 'main',
172
- expectedTargetPullRequests: [],
184
+ pullRequestStates: [],
173
185
  },
174
186
  ],
175
187
  targetBranch: '7.x',
@@ -205,26 +217,30 @@ describe('getPullRequestBody', () => {
205
217
  message: 'My commit message (#55)',
206
218
  },
207
219
  },
220
+ suggestedTargetBranches: [],
208
221
  sourceCommit: {
222
+ branchLabelMapping: {},
209
223
  committedDate: '',
210
224
  sha: 'abcdefghijklm',
211
225
  message: 'My commit message (#55)',
212
226
  },
213
227
  sourceBranch: 'main',
214
- expectedTargetPullRequests: [],
228
+ pullRequestStates: [],
215
229
  },
216
230
  {
217
231
  author: {
218
232
  email: 'soren.louv@elastic.co',
219
233
  name: 'Søren Louv-Jansen',
220
234
  },
235
+ suggestedTargetBranches: [],
221
236
  sourceCommit: {
237
+ branchLabelMapping: {},
222
238
  committedDate: '',
223
239
  sha: 'qwertyuiop',
224
240
  message: 'Another commit message',
225
241
  },
226
242
  sourceBranch: 'main',
227
- expectedTargetPullRequests: [],
243
+ pullRequestStates: [],
228
244
  },
229
245
  ],
230
246
  targetBranch: '7.x',
@@ -253,26 +269,30 @@ describe('getPullRequestBody', () => {
253
269
  message: 'My commit message (#55)',
254
270
  },
255
271
  },
272
+ suggestedTargetBranches: [],
256
273
  sourceCommit: {
274
+ branchLabelMapping: {},
257
275
  committedDate: '',
258
276
  sha: 'abcdefghijklm',
259
277
  message: 'My commit message (#55)',
260
278
  },
261
279
  sourceBranch: 'main',
262
- expectedTargetPullRequests: [],
280
+ pullRequestStates: [],
263
281
  },
264
282
  {
265
283
  author: {
266
284
  email: 'soren.louv@elastic.co',
267
285
  name: 'Søren Louv-Jansen',
268
286
  },
287
+ suggestedTargetBranches: [],
269
288
  sourceCommit: {
289
+ branchLabelMapping: {},
270
290
  committedDate: '',
271
291
  sha: 'qwertyuiop',
272
292
  message: 'Another commit message',
273
293
  },
274
294
  sourceBranch: 'main',
275
- expectedTargetPullRequests: [],
295
+ pullRequestStates: [],
276
296
  },
277
297
  ],
278
298
  targetBranch: '7.x',
@@ -311,12 +331,14 @@ describe('getTitle', () => {
311
331
  message: 'My commit message (#55)',
312
332
  },
313
333
  },
334
+ suggestedTargetBranches: [],
314
335
  sourceCommit: {
336
+ branchLabelMapping: {},
315
337
  committedDate: '2020',
316
338
  sha: 'abcdefghi',
317
339
  message: 'My commit message (#55)',
318
340
  },
319
- expectedTargetPullRequests: [],
341
+ pullRequestStates: [],
320
342
  },
321
343
  {
322
344
  author: {
@@ -331,13 +353,15 @@ describe('getTitle', () => {
331
353
  message: 'Another commit message (#56)',
332
354
  },
333
355
  },
356
+ suggestedTargetBranches: [],
334
357
  sourceCommit: {
358
+ branchLabelMapping: {},
335
359
  committedDate: '2020',
336
360
  sha: 'jklmnopqr',
337
361
  message: 'Another commit message (#56)',
338
362
  },
339
363
  sourceBranch: 'main',
340
- expectedTargetPullRequests: [],
364
+ pullRequestStates: [],
341
365
  },
342
366
  ],
343
367
  targetBranch: '7.x',
@@ -362,13 +386,15 @@ describe('getTitle', () => {
362
386
  message: 'My commit message (#55)',
363
387
  },
364
388
  },
389
+ suggestedTargetBranches: [],
365
390
  sourceCommit: {
391
+ branchLabelMapping: {},
366
392
  committedDate: '',
367
393
  sha: 'abcdefghi',
368
394
  message: 'My commit message (#55)',
369
395
  },
370
396
  sourceBranch: 'main',
371
- expectedTargetPullRequests: [],
397
+ pullRequestStates: [],
372
398
  },
373
399
  ],
374
400
  targetBranch: '7.x',
@@ -100,11 +100,14 @@ ${manualBackportCommand}${questionsAndLinkToBackport}${packageVersionSection}`;
100
100
  });
101
101
  const unmergedBackportsSection = unmergedBackports.length > 0
102
102
  ? `<br><br>You might need to backport the following PRs to ${result.targetBranch}:<br>${unmergedBackports.join('<br>')}`
103
- : '';
103
+ : undefined;
104
+ const backportFailedLabel = 'Backport failed because of merge conflicts';
104
105
  return [
105
106
  '❌',
106
107
  result.targetBranch,
107
- `**Backport failed because of merge conflicts**${unmergedBackportsSection}`,
108
+ unmergedBackportsSection
109
+ ? `**${backportFailedLabel}**${unmergedBackportsSection}`
110
+ : backportFailedLabel,
108
111
  ];
109
112
  }
110
113
  const message = result.status === 'handled-error'
@@ -279,12 +279,14 @@ describe('getCommentBody', () => {
279
279
  message: 'New Zealand commit message',
280
280
  },
281
281
  },
282
+ suggestedTargetBranches: [],
282
283
  sourceCommit: {
284
+ branchLabelMapping: {},
283
285
  committedDate: '',
284
286
  sha: '',
285
287
  message: 'New Zealand commit message',
286
288
  },
287
- expectedTargetPullRequests: [],
289
+ pullRequestStates: [],
288
290
  },
289
291
  },
290
292
  {
@@ -303,12 +305,14 @@ describe('getCommentBody', () => {
303
305
  message: 'Australia commit',
304
306
  },
305
307
  },
308
+ suggestedTargetBranches: [],
306
309
  sourceCommit: {
310
+ branchLabelMapping: {},
307
311
  committedDate: '',
308
312
  sha: '',
309
313
  message: 'Australia commit',
310
314
  },
311
- expectedTargetPullRequests: [],
315
+ pullRequestStates: [],
312
316
  },
313
317
  },
314
318
  ],
@@ -335,7 +339,7 @@ describe('getCommentBody', () => {
335
339
  |:------:|:------:|:------|
336
340
  |✅|7.x|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/55\\">](url-to-pr-55)|
337
341
  |❌|7.1|**Backport failed because of merge conflicts**<br><br>You might need to backport the following PRs to 7.1:<br> - [New Zealand commit message](url-to-pr-5)<br> - [Australia commit](url-to-pr-44)|
338
- |❌|7.2|**Backport failed because of merge conflicts**|
342
+ |❌|7.2|Backport failed because of merge conflicts|
339
343
 
340
344
  Note: Successful backport PRs will be merged automatically after passing CI.
341
345