backport 8.6.2 → 8.8.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.
Files changed (64) hide show
  1. package/dist/entrypoint.module.private.test.js +78 -52
  2. package/dist/lib/{cherrypickAndCreateTargetPullRequest.d.ts → cherrypickAndCreateTargetPullRequest/cherrypickAndCreateTargetPullRequest.d.ts} +2 -2
  3. package/dist/lib/cherrypickAndCreateTargetPullRequest/cherrypickAndCreateTargetPullRequest.js +98 -0
  4. package/dist/lib/{cherrypickAndCreateTargetPullRequest.test.d.ts → cherrypickAndCreateTargetPullRequest/cherrypickAndCreateTargetPullRequest.test.d.ts} +0 -0
  5. package/dist/lib/{cherrypickAndCreateTargetPullRequest.test.js → cherrypickAndCreateTargetPullRequest/cherrypickAndCreateTargetPullRequest.test.js} +12 -10
  6. package/dist/lib/cherrypickAndCreateTargetPullRequest/getBackportBranchName.d.ts +2 -0
  7. package/dist/lib/cherrypickAndCreateTargetPullRequest/getBackportBranchName.js +22 -0
  8. package/dist/lib/{getCommitsWithoutBackports.d.ts → cherrypickAndCreateTargetPullRequest/getCommitsWithoutBackports.d.ts} +2 -2
  9. package/dist/lib/{getCommitsWithoutBackports.js → cherrypickAndCreateTargetPullRequest/getCommitsWithoutBackports.js} +6 -6
  10. package/dist/lib/{getCommitsWithoutBackports.test.d.ts → cherrypickAndCreateTargetPullRequest/getCommitsWithoutBackports.test.d.ts} +0 -0
  11. package/dist/lib/{getCommitsWithoutBackports.test.js → cherrypickAndCreateTargetPullRequest/getCommitsWithoutBackports.test.js} +24 -17
  12. package/dist/lib/cherrypickAndCreateTargetPullRequest/getMergeCommit.d.ts +3 -0
  13. package/dist/lib/cherrypickAndCreateTargetPullRequest/getMergeCommit.js +17 -0
  14. package/dist/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels.d.ts +7 -0
  15. package/dist/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels.js +33 -0
  16. package/dist/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels.test.d.ts +1 -0
  17. package/dist/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels.test.js +166 -0
  18. package/dist/lib/cherrypickAndCreateTargetPullRequest/waitForCherrypick.d.ts +3 -0
  19. package/dist/lib/cherrypickAndCreateTargetPullRequest/waitForCherrypick.js +154 -0
  20. package/dist/lib/getSourceBranchFromCommits.d.ts +2 -0
  21. package/dist/lib/getSourceBranchFromCommits.js +10 -0
  22. package/dist/lib/getTargetBranches.js +2 -3
  23. package/dist/lib/getTargetBranches.test.js +6 -4
  24. package/dist/lib/git.test.js +1 -1
  25. package/dist/lib/github/v3/addAssigneesToPullRequest.d.ts +11 -2
  26. package/dist/lib/github/v3/addAssigneesToPullRequest.js +9 -1
  27. package/dist/lib/github/v3/addAssigneesToPullRequest.test.js +5 -2
  28. package/dist/lib/github/v3/addLabelsToPullRequest.d.ts +10 -2
  29. package/dist/lib/github/v3/addLabelsToPullRequest.js +5 -1
  30. package/dist/lib/github/v3/addReviewersToPullRequest.d.ts +1 -1
  31. package/dist/lib/github/v3/addReviewersToPullRequest.js +5 -1
  32. package/dist/lib/github/v3/createPullRequest.js +9 -2
  33. package/dist/lib/github/v3/createPullRequest.test.js +61 -56
  34. package/dist/lib/github/v3/createStatusComment.test.js +4 -2
  35. package/dist/lib/github/v4/enablePullRequestAutoMerge.js +4 -0
  36. package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +10 -1
  37. package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +5 -1
  38. package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js +3 -1
  39. package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +10 -4
  40. package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +7 -5
  41. package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +8 -2
  42. package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +6 -5
  43. package/dist/lib/prompt.test.js +14 -6
  44. package/dist/lib/prompts.js +2 -2
  45. package/dist/lib/sourceCommit/getPullRequestStates.d.ts +3 -2
  46. package/dist/lib/sourceCommit/getPullRequestStates.js +13 -20
  47. package/dist/lib/sourceCommit/getPullRequestStates.test.js +69 -28
  48. package/dist/lib/sourceCommit/parseSourceCommit.d.ts +2 -1
  49. package/dist/lib/sourceCommit/parseSourceCommit.js +15 -7
  50. package/dist/lib/sourceCommit/parseSourceCommit.test.js +15 -4
  51. package/dist/runSequentially.js +5 -5
  52. package/dist/test/e2e/cli/different-merge-strategies.private.test.js +6 -2
  53. package/dist/test/e2e/cli/gracefully-handles-corrupt-repo.private.test.js +5 -1
  54. package/dist/test/e2e/cli/repo-with-changing-branchLabelMapping.private.test.js +2 -2
  55. package/dist/test/e2e/cli/repo-with-programatically-added-commits.mutation.test.js +1 -1
  56. package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +6 -2
  57. package/dist/test/e2e/module/entrypoint.module.mutation.test.js +4 -4
  58. package/dist/test/handleUnbackportedPullRequests.private.test.js +3 -1
  59. package/dist/utils/filterUnmergedCommits.js +1 -1
  60. package/dist/utils/packageVersion.d.ts +1 -1
  61. package/dist/utils/packageVersion.js +1 -1
  62. package/package.json +11 -11
  63. package/yarn.lock +95 -139
  64. package/dist/lib/cherrypickAndCreateTargetPullRequest.js +0 -255
@@ -1,2 +1,11 @@
1
- import { ValidConfigOptions } from '../../../options/options';
2
- export declare function addAssigneesToPullRequest({ githubApiBaseUrlV3, repoName, repoOwner, accessToken, autoAssign, interactive, }: ValidConfigOptions, pullNumber: number, assignees: string[]): Promise<void>;
1
+ export declare function addAssigneesToPullRequest({ githubApiBaseUrlV3, repoName, repoOwner, accessToken, autoAssign, interactive, dryRun, pullNumber, assignees, }: {
2
+ githubApiBaseUrlV3?: string;
3
+ repoName: string;
4
+ repoOwner: string;
5
+ accessToken: string;
6
+ autoAssign: boolean;
7
+ interactive: boolean;
8
+ dryRun?: boolean;
9
+ pullNumber: number;
10
+ assignees: string[];
11
+ }): Promise<void>;
@@ -4,12 +4,20 @@ exports.addAssigneesToPullRequest = void 0;
4
4
  const rest_1 = require("@octokit/rest");
5
5
  const ora_1 = require("../../../lib/ora");
6
6
  const logger_1 = require("../../logger");
7
- async function addAssigneesToPullRequest({ githubApiBaseUrlV3, repoName, repoOwner, accessToken, autoAssign, interactive, }, pullNumber, assignees) {
7
+ async function addAssigneesToPullRequest({
8
+ // options
9
+ githubApiBaseUrlV3, repoName, repoOwner, accessToken, autoAssign, interactive, dryRun,
10
+ // additional args
11
+ pullNumber, assignees, }) {
8
12
  const text = autoAssign
9
13
  ? `Self-assigning to #${pullNumber}`
10
14
  : `Adding assignees to #${pullNumber}: ${assignees.join(', ')}`;
11
15
  logger_1.logger.info(text);
12
16
  const spinner = (0, ora_1.ora)(interactive, text).start();
17
+ if (dryRun) {
18
+ spinner.succeed();
19
+ return;
20
+ }
13
21
  try {
14
22
  const octokit = new rest_1.Octokit({
15
23
  auth: accessToken,
@@ -15,11 +15,14 @@ describe('addAssigneesToPullRequest', () => {
15
15
  })
16
16
  .reply(200, 'some response');
17
17
  const res = await (0, addAssigneesToPullRequest_1.addAssigneesToPullRequest)({
18
- author: 'sqren',
19
18
  repoName: 'kibana',
20
19
  repoOwner: 'elastic',
21
20
  accessToken: 'my-token',
22
- }, pullNumber, assignees);
21
+ autoAssign: false,
22
+ interactive: false,
23
+ pullNumber,
24
+ assignees,
25
+ });
23
26
  expect(res).toBe(undefined);
24
27
  scope.done();
25
28
  nock_1.default.cleanAll();
@@ -1,2 +1,10 @@
1
- import { ValidConfigOptions } from '../../../options/options';
2
- export declare function addLabelsToPullRequest({ githubApiBaseUrlV3, repoName, repoOwner, accessToken, interactive, }: ValidConfigOptions, pullNumber: number, labels: string[]): Promise<void>;
1
+ export declare function addLabelsToPullRequest({ githubApiBaseUrlV3, repoName, repoOwner, accessToken, interactive, dryRun, pullNumber, labels, }: {
2
+ githubApiBaseUrlV3?: string;
3
+ repoName: string;
4
+ repoOwner: string;
5
+ accessToken: string;
6
+ interactive: boolean;
7
+ dryRun?: boolean;
8
+ pullNumber: number;
9
+ labels: string[];
10
+ }): Promise<void>;
@@ -4,10 +4,14 @@ exports.addLabelsToPullRequest = void 0;
4
4
  const rest_1 = require("@octokit/rest");
5
5
  const ora_1 = require("../../../lib/ora");
6
6
  const logger_1 = require("../../logger");
7
- async function addLabelsToPullRequest({ githubApiBaseUrlV3, repoName, repoOwner, accessToken, interactive, }, pullNumber, labels) {
7
+ async function addLabelsToPullRequest({ githubApiBaseUrlV3, repoName, repoOwner, accessToken, interactive, dryRun, pullNumber, labels, }) {
8
8
  const text = `Adding labels: ${labels.join(', ')}`;
9
9
  logger_1.logger.info(text);
10
10
  const spinner = (0, ora_1.ora)(interactive, text).start();
11
+ if (dryRun) {
12
+ spinner.succeed();
13
+ return;
14
+ }
11
15
  try {
12
16
  const octokit = new rest_1.Octokit({
13
17
  auth: accessToken,
@@ -1,2 +1,2 @@
1
1
  import { ValidConfigOptions } from '../../../options/options';
2
- export declare function addReviewersToPullRequest({ githubApiBaseUrlV3, repoName, repoOwner, accessToken, interactive, }: ValidConfigOptions, pullNumber: number, reviewers: string[]): Promise<void>;
2
+ export declare function addReviewersToPullRequest({ githubApiBaseUrlV3, repoName, repoOwner, accessToken, interactive, dryRun, }: ValidConfigOptions, pullNumber: number, reviewers: string[]): Promise<void>;
@@ -4,10 +4,14 @@ exports.addReviewersToPullRequest = void 0;
4
4
  const rest_1 = require("@octokit/rest");
5
5
  const ora_1 = require("../../../lib/ora");
6
6
  const logger_1 = require("../../logger");
7
- async function addReviewersToPullRequest({ githubApiBaseUrlV3, repoName, repoOwner, accessToken, interactive, }, pullNumber, reviewers) {
7
+ async function addReviewersToPullRequest({ githubApiBaseUrlV3, repoName, repoOwner, accessToken, interactive, dryRun, }, pullNumber, reviewers) {
8
8
  const text = `Adding reviewers: ${reviewers}`;
9
9
  logger_1.logger.info(text);
10
10
  const spinner = (0, ora_1.ora)(interactive, text).start();
11
+ if (dryRun) {
12
+ spinner.succeed();
13
+ return;
14
+ }
11
15
  try {
12
16
  const octokit = new rest_1.Octokit({
13
17
  auth: accessToken,
@@ -5,6 +5,7 @@ const rest_1 = require("@octokit/rest");
5
5
  const ora_1 = require("../../../lib/ora");
6
6
  const packageVersion_1 = require("../../../utils/packageVersion");
7
7
  const BackportError_1 = require("../../BackportError");
8
+ const getSourceBranchFromCommits_1 = require("../../getSourceBranchFromCommits");
8
9
  const logger_1 = require("../../logger");
9
10
  const commitFormatters_1 = require("../commitFormatters");
10
11
  const fetchExistingPullRequest_1 = require("../v4/fetchExistingPullRequest");
@@ -13,6 +14,10 @@ async function createPullRequest({ options, prPayload, }) {
13
14
  logger_1.logger.info(`Creating PR with title: "${prPayload.title}". ${prPayload.head} -> ${prPayload.base}`);
14
15
  const { accessToken, githubApiBaseUrlV3 } = options;
15
16
  const spinner = (0, ora_1.ora)(options.interactive, `Creating pull request`).start();
17
+ if (options.dryRun) {
18
+ spinner.succeed();
19
+ return { didUpdate: false, number: 1337, url: 'this-is-a-dry-run' };
20
+ }
16
21
  try {
17
22
  const octokit = new rest_1.Octokit({
18
23
  auth: accessToken,
@@ -63,9 +68,10 @@ function getPullRequestBody({ options, commits, targetBranch, }) {
63
68
  return ` - ${message}`;
64
69
  })
65
70
  .join('\n');
71
+ const sourceBranch = (0, getSourceBranchFromCommits_1.getSourceBranchFromCommits)(commits);
66
72
  const defaultPrDescription = `# Backport
67
73
 
68
- This will backport the following commits from \`${commits[0].sourceBranch}\` to \`${targetBranch}\`:
74
+ This will backport the following commits from \`${sourceBranch}\` to \`${targetBranch}\`:
69
75
  ${commitMessages}
70
76
 
71
77
  <!--- Backport version: ${packageVersion_1.PACKAGE_VERSION} -->
@@ -75,7 +81,8 @@ Please refer to the [Backport tool documentation](https://github.com/sqren/backp
75
81
  return (options.prDescription ?? defaultPrDescription)
76
82
  .replaceAll('{targetBranch}', targetBranch)
77
83
  .replaceAll('{commitMessages}', commitMessages)
78
- .replaceAll('{defaultPrDescription}', defaultPrDescription);
84
+ .replaceAll('{defaultPrDescription}', defaultPrDescription)
85
+ .replaceAll('{commits}', JSON.stringify(commits));
79
86
  }
80
87
  exports.getPullRequestBody = getPullRequestBody;
81
88
  function getTitle({ options, commits, targetBranch, }) {
@@ -12,6 +12,7 @@ describe('getPullRequestBody', () => {
12
12
  name: 'Søren Louv-Jansen',
13
13
  },
14
14
  sourcePullRequest: {
15
+ labels: [],
15
16
  number: 55,
16
17
  url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
17
18
  mergeCommit: {
@@ -26,7 +27,7 @@ describe('getPullRequestBody', () => {
26
27
  sha: 'abcdefghi',
27
28
  message: 'My commit message (#55)',
28
29
  },
29
- pullRequestStates: [],
30
+ targetPullRequestStates: [],
30
31
  sourceBranch: 'master',
31
32
  },
32
33
  ],
@@ -60,7 +61,7 @@ describe('getPullRequestBody', () => {
60
61
  message: 'My commit message',
61
62
  },
62
63
  sourceBranch: 'main',
63
- pullRequestStates: [],
64
+ targetPullRequestStates: [],
64
65
  },
65
66
  ],
66
67
  targetBranch: '7.x',
@@ -86,6 +87,7 @@ describe('getPullRequestBody', () => {
86
87
  name: 'Søren Louv-Jansen',
87
88
  },
88
89
  sourcePullRequest: {
90
+ labels: [],
89
91
  number: 55,
90
92
  url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
91
93
  mergeCommit: {
@@ -101,7 +103,7 @@ describe('getPullRequestBody', () => {
101
103
  message: 'My commit message (#55)',
102
104
  },
103
105
  sourceBranch: 'main',
104
- pullRequestStates: [],
106
+ targetPullRequestStates: [],
105
107
  },
106
108
  {
107
109
  author: {
@@ -116,7 +118,7 @@ describe('getPullRequestBody', () => {
116
118
  message: 'Another commit message',
117
119
  },
118
120
  sourceBranch: 'main',
119
- pullRequestStates: [],
121
+ targetPullRequestStates: [],
120
122
  },
121
123
  ],
122
124
  targetBranch: '7.x',
@@ -150,6 +152,7 @@ describe('getPullRequestBody', () => {
150
152
  name: 'Søren Louv-Jansen',
151
153
  },
152
154
  sourcePullRequest: {
155
+ labels: [],
153
156
  number: 1,
154
157
  url: 'https://github.com/backport-org/different-merge-strategies/pull/1',
155
158
  mergeCommit: {
@@ -158,7 +161,7 @@ describe('getPullRequestBody', () => {
158
161
  },
159
162
  },
160
163
  sourceBranch: 'main',
161
- pullRequestStates: [],
164
+ targetPullRequestStates: [],
162
165
  },
163
166
  {
164
167
  suggestedTargetBranches: [],
@@ -173,6 +176,7 @@ describe('getPullRequestBody', () => {
173
176
  name: 'Søren Louv-Jansen',
174
177
  },
175
178
  sourcePullRequest: {
179
+ labels: [],
176
180
  number: 1,
177
181
  url: 'https://github.com/backport-org/different-merge-strategies/pull/1',
178
182
  mergeCommit: {
@@ -181,7 +185,7 @@ describe('getPullRequestBody', () => {
181
185
  },
182
186
  },
183
187
  sourceBranch: 'main',
184
- pullRequestStates: [],
188
+ targetPullRequestStates: [],
185
189
  },
186
190
  ],
187
191
  targetBranch: '7.x',
@@ -210,6 +214,7 @@ describe('getPullRequestBody', () => {
210
214
  name: 'Søren Louv-Jansen',
211
215
  },
212
216
  sourcePullRequest: {
217
+ labels: [],
213
218
  number: 55,
214
219
  url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
215
220
  mergeCommit: {
@@ -225,7 +230,7 @@ describe('getPullRequestBody', () => {
225
230
  message: 'My commit message (#55)',
226
231
  },
227
232
  sourceBranch: 'main',
228
- pullRequestStates: [],
233
+ targetPullRequestStates: [],
229
234
  },
230
235
  {
231
236
  author: {
@@ -240,7 +245,7 @@ describe('getPullRequestBody', () => {
240
245
  message: 'Another commit message',
241
246
  },
242
247
  sourceBranch: 'main',
243
- pullRequestStates: [],
248
+ targetPullRequestStates: [],
244
249
  },
245
250
  ],
246
251
  targetBranch: '7.x',
@@ -250,53 +255,30 @@ describe('getPullRequestBody', () => {
250
255
  - Another commit message (qwertyui)"
251
256
  `);
252
257
  });
253
- it('appends text to the default descriptions', () => {
254
- expect((0, createPullRequest_1.getPullRequestBody)({
255
- options: {
256
- prDescription: '{defaultPrDescription}\n\ntext to append',
257
- },
258
- commits: [
259
- {
260
- author: {
261
- email: 'soren.louv@elastic.co',
262
- name: 'Søren Louv-Jansen',
263
- },
264
- sourcePullRequest: {
265
- number: 55,
266
- url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
267
- mergeCommit: {
268
- sha: 'abcdefghijklm',
269
- message: 'My commit message (#55)',
270
- },
271
- },
272
- suggestedTargetBranches: [],
273
- sourceCommit: {
274
- branchLabelMapping: {},
275
- committedDate: '',
276
- sha: 'abcdefghijklm',
277
- message: 'My commit message (#55)',
278
- },
279
- sourceBranch: 'main',
280
- pullRequestStates: [],
258
+ it('replaces {defaultPrDescription} with the default pr description', () => {
259
+ const commits = [
260
+ {
261
+ sourcePullRequest: {
262
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
281
263
  },
282
- {
283
- author: {
284
- email: 'soren.louv@elastic.co',
285
- name: 'Søren Louv-Jansen',
286
- },
287
- suggestedTargetBranches: [],
288
- sourceCommit: {
289
- branchLabelMapping: {},
290
- committedDate: '',
291
- sha: 'qwertyuiop',
292
- message: 'Another commit message',
293
- },
294
- sourceBranch: 'main',
295
- pullRequestStates: [],
264
+ sourceCommit: {
265
+ sha: 'abcdefghijklm',
266
+ message: 'My commit message (#55)',
296
267
  },
297
- ],
298
- targetBranch: '7.x',
299
- })).toMatchInlineSnapshot(`
268
+ sourceBranch: 'main',
269
+ },
270
+ {
271
+ sourceCommit: {
272
+ sha: 'qwertyuiop',
273
+ message: 'Another commit message',
274
+ },
275
+ },
276
+ ];
277
+ const options = {
278
+ prDescription: '{defaultPrDescription}\n\ntext to append',
279
+ };
280
+ expect((0, createPullRequest_1.getPullRequestBody)({ options, commits, targetBranch: '7.x' }))
281
+ .toMatchInlineSnapshot(`
300
282
  "# Backport
301
283
 
302
284
  This will backport the following commits from \`main\` to \`7.x\`:
@@ -311,6 +293,26 @@ describe('getPullRequestBody', () => {
311
293
  text to append"
312
294
  `);
313
295
  });
296
+ it('replaces {commits} with a stringified commits object', () => {
297
+ const commits = [
298
+ {
299
+ sourceCommit: {
300
+ sha: 'foo',
301
+ message: 'My commit message (#55)',
302
+ },
303
+ },
304
+ {
305
+ sourceCommit: {
306
+ sha: 'bar',
307
+ message: 'Another commit message',
308
+ },
309
+ },
310
+ ];
311
+ const options = {
312
+ prDescription: 'Just output the commits: {commits}',
313
+ };
314
+ expect((0, createPullRequest_1.getPullRequestBody)({ options, commits, targetBranch: '7.x' })).toMatchInlineSnapshot(`"Just output the commits: [{\\"sourceCommit\\":{\\"sha\\":\\"foo\\",\\"message\\":\\"My commit message (#55)\\"}},{\\"sourceCommit\\":{\\"sha\\":\\"bar\\",\\"message\\":\\"Another commit message\\"}}]"`);
315
+ });
314
316
  });
315
317
  describe('getTitle', () => {
316
318
  it('has the default title', () => {
@@ -324,6 +326,7 @@ describe('getTitle', () => {
324
326
  },
325
327
  sourceBranch: 'main',
326
328
  sourcePullRequest: {
329
+ labels: [],
327
330
  number: 55,
328
331
  url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
329
332
  mergeCommit: {
@@ -338,7 +341,7 @@ describe('getTitle', () => {
338
341
  sha: 'abcdefghi',
339
342
  message: 'My commit message (#55)',
340
343
  },
341
- pullRequestStates: [],
344
+ targetPullRequestStates: [],
342
345
  },
343
346
  {
344
347
  author: {
@@ -346,6 +349,7 @@ describe('getTitle', () => {
346
349
  name: 'Søren Louv-Jansen',
347
350
  },
348
351
  sourcePullRequest: {
352
+ labels: [],
349
353
  number: 56,
350
354
  url: 'https://github.com/backport-org/different-merge-strategies/pull/56',
351
355
  mergeCommit: {
@@ -361,7 +365,7 @@ describe('getTitle', () => {
361
365
  message: 'Another commit message (#56)',
362
366
  },
363
367
  sourceBranch: 'main',
364
- pullRequestStates: [],
368
+ targetPullRequestStates: [],
365
369
  },
366
370
  ],
367
371
  targetBranch: '7.x',
@@ -379,6 +383,7 @@ describe('getTitle', () => {
379
383
  name: 'Søren Louv-Jansen',
380
384
  },
381
385
  sourcePullRequest: {
386
+ labels: [],
382
387
  number: 55,
383
388
  url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
384
389
  mergeCommit: {
@@ -394,7 +399,7 @@ describe('getTitle', () => {
394
399
  message: 'My commit message (#55)',
395
400
  },
396
401
  sourceBranch: 'main',
397
- pullRequestStates: [],
402
+ targetPullRequestStates: [],
398
403
  },
399
404
  ],
400
405
  targetBranch: '7.x',
@@ -272,6 +272,7 @@ describe('getCommentBody', () => {
272
272
  },
273
273
  sourceBranch: 'master',
274
274
  sourcePullRequest: {
275
+ labels: [],
275
276
  number: 5,
276
277
  url: 'url-to-pr-5',
277
278
  mergeCommit: {
@@ -286,7 +287,7 @@ describe('getCommentBody', () => {
286
287
  sha: '',
287
288
  message: 'New Zealand commit message',
288
289
  },
289
- pullRequestStates: [],
290
+ targetPullRequestStates: [],
290
291
  },
291
292
  },
292
293
  {
@@ -298,6 +299,7 @@ describe('getCommentBody', () => {
298
299
  },
299
300
  sourceBranch: 'master',
300
301
  sourcePullRequest: {
302
+ labels: [],
301
303
  number: 44,
302
304
  url: 'url-to-pr-44',
303
305
  mergeCommit: {
@@ -312,7 +314,7 @@ describe('getCommentBody', () => {
312
314
  sha: '',
313
315
  message: 'Australia commit',
314
316
  },
315
- pullRequestStates: [],
317
+ targetPullRequestStates: [],
316
318
  },
317
319
  },
318
320
  ],
@@ -14,6 +14,10 @@ async function enablePullRequestAutoMerge(options, targetPullRequestNumber) {
14
14
  const text = `Enabling auto merging via ${options.autoMergeMethod}`;
15
15
  logger_1.logger.info(text);
16
16
  const spinner = (0, ora_1.ora)(options.interactive, text).start();
17
+ if (options.dryRun) {
18
+ spinner.succeed();
19
+ return;
20
+ }
17
21
  const pullRequestId = await (0, FetchPullRequestId_1.fetchPullRequestId)(options, targetPullRequestNumber);
18
22
  const query = (0, graphql_tag_1.default) `
19
23
  mutation EnablePullRequestAutoMerge(
@@ -75,6 +75,13 @@ describe('allFetchers', () => {
75
75
  sha: 'd421ddcf6157150596581c7885afa3690cec6339',
76
76
  },
77
77
  sourcePullRequest: {
78
+ labels: [
79
+ 'Team:apm',
80
+ 'v8.0.0',
81
+ 'release_note:skip',
82
+ 'auto-backport',
83
+ 'v8.1.0',
84
+ ],
78
85
  number: 121633,
79
86
  url: 'https://github.com/elastic/kibana/pull/121633',
80
87
  mergeCommit: {
@@ -83,10 +90,11 @@ describe('allFetchers', () => {
83
90
  },
84
91
  },
85
92
  sourceBranch: 'main',
86
- pullRequestStates: [
93
+ targetPullRequestStates: [
87
94
  {
88
95
  branch: '8.0',
89
96
  label: 'v8.0.0',
97
+ labelRegex: '^v(\\d+).(\\d+).\\d+$',
90
98
  isSourceBranch: false,
91
99
  mergeCommit: {
92
100
  message: '[APM] Add note about synthtrace to APM docs (#121633) (#121643)\n\nCo-authored-by: Søren Louv-Jansen <soren.louv@elastic.co>',
@@ -99,6 +107,7 @@ describe('allFetchers', () => {
99
107
  {
100
108
  branch: 'main',
101
109
  label: 'v8.1.0',
110
+ labelRegex: '^v8.1.0$',
102
111
  isSourceBranch: true,
103
112
  mergeCommit: {
104
113
  message: '[APM] Add note about synthtrace to APM docs (#121633)',
@@ -81,6 +81,7 @@ describe('fetchCommitByPullNumber', () => {
81
81
  sha: 'ee8c492334cef1ca077a56addb79a26f79821d2f',
82
82
  },
83
83
  sourcePullRequest: {
84
+ labels: ['v7.8.0', 'v7.9.0', 'v8.0.0'],
84
85
  number: 5,
85
86
  url: 'https://github.com/backport-org/backport-e2e/pull/5',
86
87
  mergeCommit: {
@@ -89,11 +90,12 @@ describe('fetchCommitByPullNumber', () => {
89
90
  },
90
91
  },
91
92
  sourceBranch: 'master',
92
- pullRequestStates: [
93
+ targetPullRequestStates: [
93
94
  {
94
95
  branch: '7.8',
95
96
  isSourceBranch: false,
96
97
  label: 'v7.8.0',
98
+ labelRegex: '^v(\\d+).(\\d+).\\d+$',
97
99
  mergeCommit: {
98
100
  message: 'Add 🍏 emoji (#5) (#7)',
99
101
  sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
@@ -106,6 +108,7 @@ describe('fetchCommitByPullNumber', () => {
106
108
  branch: '7.x',
107
109
  isSourceBranch: false,
108
110
  label: 'v7.9.0',
111
+ labelRegex: '^v7.9.0$',
109
112
  mergeCommit: {
110
113
  message: 'Add 🍏 emoji (#5) (#6)',
111
114
  sha: '4bcd876d4ceaa73cf437bfc89b74d1a4e704c0a6',
@@ -118,6 +121,7 @@ describe('fetchCommitByPullNumber', () => {
118
121
  branch: 'master',
119
122
  isSourceBranch: true,
120
123
  label: 'v8.0.0',
124
+ labelRegex: '^v8.0.0$',
121
125
  mergeCommit: {
122
126
  message: 'Add 🍏 emoji (#5)',
123
127
  sha: 'ee8c492334cef1ca077a56addb79a26f79821d2f',
@@ -74,6 +74,7 @@ describe('fetchCommitBySha', () => {
74
74
  sha: 'cb6fbc0e1b406675724181a3e9f59459b5f8f892',
75
75
  },
76
76
  sourcePullRequest: {
77
+ labels: ['Team:apm', 'release_note:skip', 'v7.9.0'],
77
78
  number: 70740,
78
79
  url: 'https://github.com/elastic/kibana/pull/70740',
79
80
  mergeCommit: {
@@ -82,10 +83,11 @@ describe('fetchCommitBySha', () => {
82
83
  },
83
84
  },
84
85
  sourceBranch: 'master',
85
- pullRequestStates: [
86
+ targetPullRequestStates: [
86
87
  {
87
88
  branch: '7.x',
88
89
  label: 'v7.9.0',
90
+ labelRegex: '^v7.9.0$',
89
91
  isSourceBranch: false,
90
92
  state: 'MERGED',
91
93
  number: 71014,
@@ -135,7 +135,7 @@ describe('fetchCommitsByAuthor', () => {
135
135
  ]);
136
136
  });
137
137
  });
138
- describe('pullRequestStates', () => {
138
+ describe('targetPullRequestStates', () => {
139
139
  let res;
140
140
  beforeEach(async () => {
141
141
  res = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
@@ -152,10 +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?.pullRequestStates).toEqual([
155
+ expect(commitWithOpenPR?.targetPullRequestStates).toEqual([
156
156
  {
157
157
  branch: '7.8',
158
158
  label: 'v7.8.0',
159
+ labelRegex: '^v(\\d+).(\\d+).\\d+$',
159
160
  isSourceBranch: false,
160
161
  state: 'OPEN',
161
162
  number: 10,
@@ -165,10 +166,11 @@ describe('fetchCommitsByAuthor', () => {
165
166
  });
166
167
  it('returns related MERGED PRs', async () => {
167
168
  const commitWithMergedPRs = res.find((commit) => commit.sourcePullRequest?.number === 5);
168
- expect(commitWithMergedPRs?.pullRequestStates).toEqual([
169
+ expect(commitWithMergedPRs?.targetPullRequestStates).toEqual([
169
170
  {
170
171
  branch: '7.8',
171
172
  label: 'v7.8.0',
173
+ labelRegex: '^v(\\d+).(\\d+).\\d+$',
172
174
  isSourceBranch: false,
173
175
  mergeCommit: {
174
176
  message: 'Add 🍏 emoji (#5) (#7)',
@@ -181,6 +183,7 @@ describe('fetchCommitsByAuthor', () => {
181
183
  {
182
184
  branch: '7.x',
183
185
  label: 'v7.9.0',
186
+ labelRegex: '^v7.9.0$',
184
187
  isSourceBranch: false,
185
188
  mergeCommit: {
186
189
  message: 'Add 🍏 emoji (#5) (#6)',
@@ -193,6 +196,7 @@ describe('fetchCommitsByAuthor', () => {
193
196
  {
194
197
  branch: 'master',
195
198
  label: 'v8.0.0',
199
+ labelRegex: '^v8.0.0$',
196
200
  isSourceBranch: true,
197
201
  mergeCommit: {
198
202
  message: 'Add 🍏 emoji (#5)',
@@ -206,16 +210,18 @@ describe('fetchCommitsByAuthor', () => {
206
210
  });
207
211
  it('returns missing pull requests', async () => {
208
212
  const commitWithoutPRs = res.find((commit) => commit.sourcePullRequest?.number === 8);
209
- expect(commitWithoutPRs?.pullRequestStates).toEqual([
213
+ expect(commitWithoutPRs?.targetPullRequestStates).toEqual([
210
214
  {
211
215
  branch: '7.x',
212
216
  label: 'v7.9.0',
217
+ labelRegex: '^v7.9.0$',
213
218
  isSourceBranch: false,
214
219
  state: 'NOT_CREATED',
215
220
  },
216
221
  {
217
222
  branch: 'master',
218
223
  label: 'v8.0.0',
224
+ labelRegex: '^v8.0.0$',
219
225
  isSourceBranch: true,
220
226
  mergeCommit: {
221
227
  message: 'Change Ulysses to Gretha (conflict) (#8)',