backport 7.3.6 → 7.4.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 (50) hide show
  1. package/README.md +1 -5
  2. package/dist/backportRun.d.ts +9 -3
  3. package/dist/backportRun.js +18 -9
  4. package/dist/entrypoint.cli.js +1 -1
  5. package/dist/entrypoint.module.js +5 -1
  6. package/dist/entrypoint.module.private.test.js +103 -5
  7. package/dist/options/ConfigOptions.d.ts +2 -2
  8. package/dist/options/cliArgs.d.ts +1 -2
  9. package/dist/options/cliArgs.js +4 -6
  10. package/dist/options/config/config.d.ts +2 -2
  11. package/dist/options/config/config.js +2 -2
  12. package/dist/options/config/projectConfig.d.ts +2 -2
  13. package/dist/options/config/projectConfig.js +3 -3
  14. package/dist/options/config/projectConfig.test.js +19 -7
  15. package/dist/options/config/readConfigFile.d.ts +2 -2
  16. package/dist/options/options.d.ts +1 -2
  17. package/dist/options/options.js +2 -3
  18. package/dist/options/options.test.js +2 -3
  19. package/dist/runSequentially.d.ts +1 -1
  20. package/dist/runSequentially.js +0 -1
  21. package/dist/services/HandledError.d.ts +6 -2
  22. package/dist/services/HandledError.js +8 -8
  23. package/dist/services/git.js +0 -4
  24. package/dist/services/git.test.js +0 -34
  25. package/dist/services/github/v3/createStatusComment.js +3 -2
  26. package/dist/services/github/v3/createStatusComment.test.js +2 -0
  27. package/dist/services/github/v4/apiRequestV4.js +6 -9
  28. package/dist/services/github/v4/fetchAuthorId.private.test.js +3 -6
  29. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +5 -6
  30. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +5 -8
  31. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +5 -8
  32. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +4 -7
  33. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +3 -6
  34. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +3 -6
  35. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +4 -7
  36. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +2 -2
  37. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +6 -7
  38. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +4 -7
  39. package/dist/services/logger.d.ts +1 -4
  40. package/dist/services/logger.js +9 -18
  41. package/dist/test/e2e/cli/entrypoint.cli.private.test.d.ts +1 -0
  42. package/dist/test/e2e/cli/entrypoint.cli.private.test.js +219 -0
  43. package/dist/test/e2e/module/entrypoint.module.mutation.test.d.ts +1 -0
  44. package/dist/test/e2e/module/entrypoint.module.mutation.test.js +369 -0
  45. package/dist/test/handleUnbackportedPullRequests.private.test.js +1 -2
  46. package/dist/test/setupFiles/automatic-mocks.js +11 -11
  47. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +7 -3
  48. package/dist/utils/packageVersion.d.ts +1 -1
  49. package/dist/utils/packageVersion.js +1 -1
  50. package/package.json +1 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ## 🎉 New! The Backport Tool as a Github Action 🎉
10
10
 
11
- A [Github Action](https://github.com/elastic/kibana-github-actions/tree/main/backport) around The Backport Tool now exists. It makes it a breeze to get automatic backports when pull requests are merged.
11
+ A [Github Action](https://github.com/sqren/backport-github-action) around The Backport Tool now exists. It makes it a breeze to get automatic backports when pull requests are merged.
12
12
 
13
13
  # Backport CLI tool
14
14
 
@@ -244,10 +244,6 @@ console.log(commits);
244
244
  */
245
245
  ```
246
246
 
247
- ## The Backport Tool as a Github Action
248
-
249
- A [Github Action](https://github.com/elastic/kibana-github-actions/tree/main/backport) around The Backport Tool for automatically creating backports when pull requests are merged.
250
-
251
247
  ## What is backporting?
252
248
 
253
249
  > Backporting is the action of taking parts from a newer version of a software system [..] and porting them to an older version of the same software. It forms part of the maintenance step in a software development process, and it is commonly used for fixing security issues in older versions of the software and also for providing new features to older versions.
@@ -2,14 +2,20 @@ import { ConfigFileOptions } from './options/ConfigOptions';
2
2
  import { Result } from './runSequentially';
3
3
  import { HandledError } from './services/HandledError';
4
4
  import { Commit } from './services/sourceCommit/parseSourceCommit';
5
- export declare type BackportResponse = {
5
+ export declare type BackportSuccessResponse = {
6
6
  status: 'success';
7
7
  commits: Commit[];
8
8
  results: Result[];
9
- } | {
9
+ };
10
+ export declare type BackportFailureResponse = {
10
11
  status: 'failure';
11
12
  commits: Commit[];
12
13
  error: Error | HandledError;
13
14
  errorMessage: string;
14
15
  };
15
- export declare function backportRun(processArgs: string[], optionsFromModule?: ConfigFileOptions): Promise<BackportResponse>;
16
+ export declare type BackportResponse = BackportSuccessResponse | BackportFailureResponse;
17
+ export declare function backportRun({ processArgs, optionsFromModule, isCliMode, }: {
18
+ processArgs: string[];
19
+ optionsFromModule?: ConfigFileOptions;
20
+ isCliMode: boolean;
21
+ }): Promise<BackportResponse>;
@@ -18,14 +18,14 @@ const getGitConfigAuthor_1 = require("./ui/getGitConfigAuthor");
18
18
  const getTargetBranches_1 = require("./ui/getTargetBranches");
19
19
  const ora_1 = require("./ui/ora");
20
20
  const setupRepo_1 = require("./ui/setupRepo");
21
- async function backportRun(processArgs, optionsFromModule = {}) {
21
+ async function backportRun({ processArgs, optionsFromModule = {}, isCliMode, }) {
22
22
  const argv = (0, yargs_parser_1.default)(processArgs);
23
23
  const ci = argv.ci ?? optionsFromModule.ci;
24
24
  const ls = argv.ls ?? optionsFromModule.ls;
25
25
  const logFilePath = argv.logFilePath ?? optionsFromModule.logFilePath;
26
- (0, logger_1.initLogger)({ ci, logFilePath });
27
- // don't show spinner for yargs commands that exit the process without stopping the spinner first
26
+ const logger = (0, logger_1.initLogger)({ ci, logFilePath });
28
27
  const spinner = (0, ora_1.ora)(ci);
28
+ // don't show spinner for yargs commands that exit the process without stopping the spinner first
29
29
  if (!argv.help && !argv.version && !argv.v) {
30
30
  spinner.start('Initializing...');
31
31
  }
@@ -33,10 +33,10 @@ async function backportRun(processArgs, optionsFromModule = {}) {
33
33
  let commits = [];
34
34
  try {
35
35
  options = await (0, options_1.getOptions)(processArgs, optionsFromModule);
36
- logger_1.logger.info('Backporting options', options);
36
+ logger.info('Backporting options', options);
37
37
  spinner.stop();
38
38
  commits = await (0, getCommits_1.getCommits)(options);
39
- logger_1.logger.info('Commits', commits);
39
+ logger.info('Commits', commits);
40
40
  if (options.ls) {
41
41
  return {
42
42
  status: 'success',
@@ -45,7 +45,7 @@ async function backportRun(processArgs, optionsFromModule = {}) {
45
45
  };
46
46
  }
47
47
  const targetBranches = await (0, getTargetBranches_1.getTargetBranches)(options, commits);
48
- logger_1.logger.info('Target branches', targetBranches);
48
+ logger.info('Target branches', targetBranches);
49
49
  const [gitConfigAuthor] = await Promise.all([
50
50
  (0, getGitConfigAuthor_1.getGitConfigAuthor)(options),
51
51
  (0, setupRepo_1.setupRepo)(options),
@@ -56,7 +56,7 @@ async function backportRun(processArgs, optionsFromModule = {}) {
56
56
  targetBranches,
57
57
  gitConfigAuthor,
58
58
  });
59
- logger_1.logger.info('Results', results);
59
+ logger.info('Results', results);
60
60
  const backportResponse = {
61
61
  status: 'success',
62
62
  commits,
@@ -85,8 +85,10 @@ async function backportRun(processArgs, optionsFromModule = {}) {
85
85
  if (!ls) {
86
86
  outputError({ e, logFilePath });
87
87
  }
88
- logger_1.logger.error('Unhandled exception', e);
89
- process.exitCode = 1;
88
+ logger.error('Unhandled exception', e);
89
+ if (isCliMode && isCriticalError(e)) {
90
+ process.exitCode = 1;
91
+ }
90
92
  return backportResponse;
91
93
  }
92
94
  }
@@ -107,3 +109,10 @@ function outputError({ e, logFilePath, }) {
107
109
  })}`));
108
110
  }
109
111
  }
112
+ function isCriticalError(e) {
113
+ if (e instanceof HandledError_1.HandledError &&
114
+ e.errorContext.code === 'no-branches-exception') {
115
+ return false;
116
+ }
117
+ return true;
118
+ }
@@ -7,7 +7,7 @@ const yargs_parser_1 = __importDefault(require("yargs-parser"));
7
7
  const backportRun_1 = require("./backportRun");
8
8
  const processArgs = process.argv.slice(2);
9
9
  // this is the entrypoint when running from command line
10
- (0, backportRun_1.backportRun)(processArgs).then((backportResponse) => {
10
+ (0, backportRun_1.backportRun)({ processArgs, isCliMode: true }).then((backportResponse) => {
11
11
  const argv = (0, yargs_parser_1.default)(processArgs);
12
12
  const { ci, ls } = argv;
13
13
  if (ci || ls) {
@@ -22,7 +22,11 @@ function backportRun(options,
22
22
  // backportRun(options, args)
23
23
  //
24
24
  processArgs = []) {
25
- return (0, backportRun_1.backportRun)(processArgs, (0, excludeUndefined_1.excludeUndefined)(options));
25
+ return (0, backportRun_1.backportRun)({
26
+ processArgs,
27
+ optionsFromModule: (0, excludeUndefined_1.excludeUndefined)(options),
28
+ isCliMode: false,
29
+ });
26
30
  }
27
31
  exports.backportRun = backportRun;
28
32
  async function getCommits(options) {
@@ -2,10 +2,112 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const entrypoint_module_1 = require("./entrypoint.module");
4
4
  const getDevAccessToken_1 = require("./test/private/getDevAccessToken");
5
+ const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
6
+ jest.unmock('del');
7
+ jest.unmock('make-dir');
8
+ jest.unmock('find-up');
5
9
  describe('entrypoint.module', () => {
10
+ describe('backportRun', () => {
11
+ describe('when running into merge conflict', () => {
12
+ let response;
13
+ beforeAll(async () => {
14
+ response = (await (0, entrypoint_module_1.backportRun)({
15
+ repoOwner: 'backport-org',
16
+ repoName: 'repo-with-conflicts',
17
+ ci: true,
18
+ accessToken,
19
+ pullNumber: 12,
20
+ targetBranches: ['7.x'],
21
+ }));
22
+ });
23
+ it('should have overall status=success', async () => {
24
+ expect(response.status).toBe('success');
25
+ });
26
+ it('should have a failed result', () => {
27
+ expect(response.results[0].status).toBe('failure');
28
+ });
29
+ it('should have correct error code', () => {
30
+ //@ts-expect-error
31
+ expect(response.results[0].error.errorContext.code).toBe('merge-conflict-exception');
32
+ });
33
+ it('contains a list of conflicting files', () => {
34
+ //@ts-expect-error
35
+ expect(response.results[0].error.errorContext.conflictingFiles).toEqual(['la-liga.md']);
36
+ });
37
+ });
38
+ describe('when missing branches to backport to', () => {
39
+ let response;
40
+ beforeAll(async () => {
41
+ response = (await (0, entrypoint_module_1.backportRun)({
42
+ repoOwner: 'backport-org',
43
+ repoName: 'repo-with-conflicts',
44
+ ci: true,
45
+ accessToken,
46
+ pullNumber: 12,
47
+ }));
48
+ });
49
+ it('should return conflict in response', async () => {
50
+ expect(response.status).toBe('failure');
51
+ //@ts-expect-error
52
+ expect(response.error.errorContext.code).toBe('no-branches-exception');
53
+ });
54
+ });
55
+ describe('when backporting', () => {
56
+ let response;
57
+ beforeAll(async () => {
58
+ response = (await (0, entrypoint_module_1.backportRun)({
59
+ repoOwner: 'backport-org',
60
+ repoName: 'repo-with-conflicts',
61
+ ci: true,
62
+ accessToken,
63
+ pullNumber: 8,
64
+ dryRun: true,
65
+ }));
66
+ });
67
+ it('should return successful backport response', async () => {
68
+ expect(response.status).toBe('success');
69
+ expect(response).toEqual({
70
+ status: 'success',
71
+ results: [
72
+ {
73
+ status: 'success',
74
+ didUpdate: false,
75
+ pullRequestNumber: 1337,
76
+ pullRequestUrl: 'https://localhost/dry-run',
77
+ targetBranch: '7.x',
78
+ },
79
+ ],
80
+ commits: [
81
+ {
82
+ author: {
83
+ email: 'sorenlouv@gmail.com',
84
+ name: 'Søren Louv-Jansen',
85
+ },
86
+ expectedTargetPullRequests: [
87
+ { branch: '7.x', state: 'NOT_CREATED' },
88
+ ],
89
+ sourceBranch: 'main',
90
+ sourceCommit: {
91
+ committedDate: '2021-12-16T00:03:34Z',
92
+ message: 'Change Barca to Braithwaite (#8)',
93
+ sha: '343402a748be2375325b2730fa979bcea5b96ba1',
94
+ },
95
+ sourcePullRequest: {
96
+ mergeCommit: {
97
+ message: 'Change Barca to Braithwaite (#8)',
98
+ sha: '343402a748be2375325b2730fa979bcea5b96ba1',
99
+ },
100
+ number: 8,
101
+ url: 'https://github.com/backport-org/repo-with-conflicts/pull/8',
102
+ },
103
+ },
104
+ ],
105
+ });
106
+ });
107
+ });
108
+ });
6
109
  describe('getCommits', () => {
7
110
  it('pullNumber', async () => {
8
- const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
9
111
  const commits = await (0, entrypoint_module_1.getCommits)({
10
112
  accessToken: accessToken,
11
113
  repoName: 'kibana',
@@ -56,7 +158,6 @@ describe('entrypoint.module', () => {
56
158
  expect(commits).toEqual(expectedCommits);
57
159
  });
58
160
  it('sha', async () => {
59
- const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
60
161
  const commits = await (0, entrypoint_module_1.getCommits)({
61
162
  accessToken: accessToken,
62
163
  repoName: 'kibana',
@@ -107,7 +208,6 @@ describe('entrypoint.module', () => {
107
208
  expect(commits).toEqual(expectedCommits);
108
209
  });
109
210
  it('prFilter', async () => {
110
- const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
111
211
  const commits = await (0, entrypoint_module_1.getCommits)({
112
212
  accessToken: accessToken,
113
213
  repoName: 'kibana',
@@ -451,7 +551,6 @@ describe('entrypoint.module', () => {
451
551
  `);
452
552
  });
453
553
  it('author', async () => {
454
- const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
455
554
  const commits = await (0, entrypoint_module_1.getCommits)({
456
555
  accessToken: accessToken,
457
556
  repoName: 'kibana',
@@ -580,7 +679,6 @@ describe('entrypoint.module', () => {
580
679
  `);
581
680
  });
582
681
  it('throws when missing a filter', async () => {
583
- const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
584
682
  await expect(() => (0, entrypoint_module_1.getCommits)({
585
683
  accessToken: accessToken,
586
684
  repoName: 'kibana',
@@ -22,9 +22,9 @@ declare type Options = Partial<{
22
22
  cherrypickRef: boolean;
23
23
  ci: boolean;
24
24
  commitPaths: string[];
25
- configFile: string;
26
25
  details: boolean;
27
26
  dir: string;
27
+ dryRun: boolean;
28
28
  editor: string;
29
29
  fork: boolean;
30
30
  gitAuthorEmail: string;
@@ -41,6 +41,7 @@ declare type Options = Partial<{
41
41
  noVerify: boolean;
42
42
  prDescription: string;
43
43
  prFilter: string;
44
+ projectConfigFile: string;
44
45
  prTitle: string;
45
46
  publishStatusComment: boolean;
46
47
  pullNumber: number;
@@ -56,7 +57,6 @@ declare type Options = Partial<{
56
57
  targetBranchChoices: TargetBranchChoiceOrString[];
57
58
  targetBranches: string[];
58
59
  targetPRLabels: string[];
59
- verbose: boolean;
60
60
  }>;
61
61
  export declare type ConfigFileOptions = Options & Partial<{
62
62
  help: boolean;
@@ -4,7 +4,6 @@ export declare function getOptionsFromCliArgs(processArgs: readonly string[], {
4
4
  }): {
5
5
  fork?: boolean | undefined;
6
6
  dir?: string | undefined;
7
- verbose?: boolean | undefined;
8
7
  logFilePath?: string | undefined;
9
8
  accessToken?: string | undefined;
10
9
  author?: string | null | undefined;
@@ -14,7 +13,7 @@ export declare function getOptionsFromCliArgs(processArgs: readonly string[], {
14
13
  autoMergeMethod?: string | undefined;
15
14
  ci?: boolean | undefined;
16
15
  cherrypickRef?: boolean | undefined;
17
- configFile?: string | undefined;
16
+ projectConfigFile?: string | undefined;
18
17
  details?: boolean | undefined;
19
18
  dryRun?: boolean | undefined;
20
19
  editor?: string | undefined;
@@ -8,6 +8,7 @@ const yargs_1 = __importDefault(require("yargs"));
8
8
  const excludeUndefined_1 = require("../utils/excludeUndefined");
9
9
  function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
10
10
  const yargsInstance = (0, yargs_1.default)(processArgs)
11
+ .strict()
11
12
  .parserConfiguration({
12
13
  'strip-dashed': true,
13
14
  'strip-aliased': true,
@@ -63,7 +64,7 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
63
64
  type: 'boolean',
64
65
  conflicts: ['noCherrypickRef'],
65
66
  })
66
- .option('configFile', {
67
+ .option('projectConfigFile', {
67
68
  alias: 'config',
68
69
  description: 'Path to project config',
69
70
  type: 'string',
@@ -239,11 +240,13 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
239
240
  conflicts: ['noFork'],
240
241
  })
241
242
  .option('repoOwner', {
243
+ hidden: true,
242
244
  description: 'Repository owner',
243
245
  type: 'string',
244
246
  conflicts: ['repo'],
245
247
  })
246
248
  .option('repoName', {
249
+ hidden: true,
247
250
  description: 'Repository name',
248
251
  type: 'string',
249
252
  conflicts: ['repo'],
@@ -285,10 +288,6 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
285
288
  alias: ['label', 'l'],
286
289
  type: 'array',
287
290
  string: true,
288
- })
289
- .option('verbose', {
290
- description: 'Show additional debug information',
291
- type: 'boolean',
292
291
  })
293
292
  // cli-only
294
293
  .option('verify', {
@@ -296,7 +295,6 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
296
295
  type: 'boolean',
297
296
  })
298
297
  .alias('version', 'v')
299
- .alias('version', 'V')
300
298
  .help()
301
299
  .epilogue('For bugs, feature requests or questions: https://github.com/sqren/backport/issues\nOr contact me directly: https://twitter.com/sorenlouv');
302
300
  // don't kill process upon error
@@ -22,9 +22,9 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
22
22
  cherrypickRef?: boolean | undefined;
23
23
  ci?: boolean | undefined;
24
24
  commitPaths?: string[] | undefined;
25
- configFile?: string | undefined;
26
25
  details?: boolean | undefined;
27
26
  dir?: string | undefined;
27
+ dryRun?: boolean | undefined;
28
28
  editor?: string | undefined;
29
29
  fork?: boolean | undefined;
30
30
  gitAuthorEmail?: string | undefined;
@@ -41,6 +41,7 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
41
41
  noVerify?: boolean | undefined;
42
42
  prDescription?: string | undefined;
43
43
  prFilter?: string | undefined;
44
+ projectConfigFile?: string | undefined;
44
45
  prTitle?: string | undefined;
45
46
  publishStatusComment?: boolean | undefined;
46
47
  pullNumber?: number | undefined;
@@ -56,7 +57,6 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
56
57
  targetBranchChoices?: import("../ConfigOptions").TargetBranchChoiceOrString[] | undefined;
57
58
  targetBranches?: string[] | undefined;
58
59
  targetPRLabels?: string[] | undefined;
59
- verbose?: boolean | undefined;
60
60
  help?: boolean | undefined;
61
61
  version?: boolean | undefined;
62
62
  v?: boolean | undefined;
@@ -7,9 +7,9 @@ async function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsFromModule
7
7
  // ci: cli and module only flag
8
8
  const ci = optionsFromCliArgs.ci ?? optionsFromModule.ci ?? defaultConfigOptions.ci;
9
9
  // ci: cli and module only flag
10
- const configFile = optionsFromCliArgs.configFile ?? optionsFromModule.configFile;
10
+ const projectConfigFile = optionsFromCliArgs.projectConfigFile ?? optionsFromModule.projectConfigFile;
11
11
  const [projectConfig, globalConfig] = await Promise.all([
12
- (0, projectConfig_1.getProjectConfig)({ configFile }),
12
+ (0, projectConfig_1.getProjectConfig)({ projectConfigFile }),
13
13
  ci ? undefined : (0, globalConfig_1.getGlobalConfig)(),
14
14
  ]);
15
15
  return {
@@ -1,4 +1,4 @@
1
1
  import { ConfigFileOptions } from '../ConfigOptions';
2
- export declare function getProjectConfig({ configFile, }: {
3
- configFile: string | undefined;
2
+ export declare function getProjectConfig({ projectConfigFile, }: {
3
+ projectConfigFile: string | undefined;
4
4
  }): Promise<ConfigFileOptions | undefined>;
@@ -7,9 +7,9 @@ exports.getProjectConfig = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const find_up_1 = __importDefault(require("find-up"));
9
9
  const readConfigFile_1 = require("../config/readConfigFile");
10
- async function getProjectConfig({ configFile, }) {
11
- const filepath = configFile
12
- ? path_1.default.resolve(configFile)
10
+ async function getProjectConfig({ projectConfigFile, }) {
11
+ const filepath = projectConfigFile
12
+ ? path_1.default.resolve(projectConfigFile)
13
13
  : await (0, find_up_1.default)('.backportrc.json');
14
14
  if (!filepath) {
15
15
  return;
@@ -16,7 +16,9 @@ describe('getProjectConfig', () => {
16
16
  repoOwner: 'elastic',
17
17
  branches: ['6.x'],
18
18
  }));
19
- const projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
19
+ const projectConfig = await (0, projectConfig_1.getProjectConfig)({
20
+ projectConfigFile: undefined,
21
+ });
20
22
  expect(projectConfig?.targetBranchChoices).toEqual(['6.x']);
21
23
  });
22
24
  });
@@ -25,7 +27,9 @@ describe('getProjectConfig', () => {
25
27
  jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce(JSON.stringify({
26
28
  labels: ['backport'],
27
29
  }));
28
- const projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
30
+ const projectConfig = await (0, projectConfig_1.getProjectConfig)({
31
+ projectConfigFile: undefined,
32
+ });
29
33
  expect(projectConfig?.targetPRLabels).toEqual(['backport']);
30
34
  });
31
35
  });
@@ -34,7 +38,9 @@ describe('getProjectConfig', () => {
34
38
  jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce(JSON.stringify({
35
39
  upstream: 'elastic/kibana',
36
40
  }));
37
- const projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
41
+ const projectConfig = await (0, projectConfig_1.getProjectConfig)({
42
+ projectConfigFile: undefined,
43
+ });
38
44
  expect(projectConfig?.repoOwner).toEqual('elastic');
39
45
  expect(projectConfig?.repoName).toEqual('kibana');
40
46
  });
@@ -48,7 +54,9 @@ describe('getProjectConfig', () => {
48
54
  targetBranchChoices: ['6.x'],
49
55
  targetPRLabels: ['backport'],
50
56
  }));
51
- projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
57
+ projectConfig = await (0, projectConfig_1.getProjectConfig)({
58
+ projectConfigFile: undefined,
59
+ });
52
60
  });
53
61
  it('should call findUp', () => {
54
62
  expect(find_up_1.default).toHaveBeenCalledWith('.backportrc.json');
@@ -73,7 +81,7 @@ describe('getProjectConfig', () => {
73
81
  targetPRLabels: ['backport'],
74
82
  }));
75
83
  projectConfig = await (0, projectConfig_1.getProjectConfig)({
76
- configFile: '/custom/path/to/project/.backportrc.json',
84
+ projectConfigFile: '/custom/path/to/project/.backportrc.json',
77
85
  });
78
86
  });
79
87
  it('should not call findUp', () => {
@@ -95,14 +103,18 @@ describe('getProjectConfig', () => {
95
103
  describe('when projectConfig is empty', () => {
96
104
  it('should return empty config', async () => {
97
105
  jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce('{}');
98
- const projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
106
+ const projectConfig = await (0, projectConfig_1.getProjectConfig)({
107
+ projectConfigFile: undefined,
108
+ });
99
109
  expect(projectConfig).toEqual({});
100
110
  });
101
111
  });
102
112
  describe('when projectConfig is missing', () => {
103
113
  it('should return empty config', async () => {
104
114
  find_up_1.default.mockReturnValueOnce(undefined);
105
- const projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
115
+ const projectConfig = await (0, projectConfig_1.getProjectConfig)({
116
+ projectConfigFile: undefined,
117
+ });
106
118
  expect(projectConfig).toEqual(undefined);
107
119
  });
108
120
  });
@@ -4,7 +4,6 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
4
4
  fork?: boolean | undefined;
5
5
  dir?: string | undefined;
6
6
  help?: boolean | undefined;
7
- verbose?: boolean | undefined;
8
7
  logFilePath?: string | undefined;
9
8
  accessToken?: string | undefined;
10
9
  author?: string | null | undefined;
@@ -14,8 +13,9 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
14
13
  autoMergeMethod?: string | undefined;
15
14
  ci?: boolean | undefined;
16
15
  cherrypickRef?: boolean | undefined;
17
- configFile?: string | undefined;
16
+ projectConfigFile?: string | undefined;
18
17
  details?: boolean | undefined;
18
+ dryRun?: boolean | undefined;
19
19
  editor?: string | undefined;
20
20
  skipRemoteConfig?: boolean | undefined;
21
21
  gitHostname?: string | undefined;
@@ -6,7 +6,6 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
6
6
  repoOwner: string;
7
7
  fork: boolean;
8
8
  dir?: string | undefined;
9
- verbose: boolean;
10
9
  logFilePath?: string | undefined;
11
10
  author: string | null;
12
11
  autoAssign: boolean;
@@ -15,7 +14,7 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
15
14
  autoMergeMethod: string;
16
15
  ci: boolean;
17
16
  cherrypickRef: boolean;
18
- configFile?: string | undefined;
17
+ projectConfigFile?: string | undefined;
19
18
  details: boolean;
20
19
  dryRun?: boolean | undefined;
21
20
  editor?: string | undefined;
@@ -37,7 +37,6 @@ const defaultConfigOptions = {
37
37
  targetBranchChoices: [],
38
38
  targetBranches: [],
39
39
  targetPRLabels: [],
40
- verbose: false,
41
40
  };
42
41
  async function getOptions(processArgs, optionsFromModule) {
43
42
  const optionsFromCliArgs = (0, cliArgs_1.getOptionsFromCliArgs)(processArgs);
@@ -53,7 +52,7 @@ async function getOptions(processArgs, optionsFromModule) {
53
52
  });
54
53
  const { accessToken, repoName, repoOwner } = await getRequiredOptions(combined);
55
54
  // update logger
56
- (0, logger_1.updateLogger)({ accessToken, verbose: combined.verbose });
55
+ (0, logger_1.setAccessToken)(accessToken);
57
56
  const optionsFromGithub = await (0, getOptionsFromGithub_1.getOptionsFromGithub)({
58
57
  ...combined,
59
58
  // required options
@@ -124,7 +123,6 @@ function throwForRequiredOptions(options) {
124
123
  'author',
125
124
  'autoMergeMethod',
126
125
  'backportBinary',
127
- 'configFile',
128
126
  'dir',
129
127
  'editor',
130
128
  'gitHostname',
@@ -133,6 +131,7 @@ function throwForRequiredOptions(options) {
133
131
  'logFilePath',
134
132
  'prDescription',
135
133
  'prFilter',
134
+ 'projectConfigFile',
136
135
  'prTitle',
137
136
  'repoForkOwner',
138
137
  'repoName',
@@ -151,10 +151,10 @@ describe('getOptions', () => {
151
151
  const options = await (0, options_1.getOptions)([], { autoFixConflicts: myFn });
152
152
  expect(options.autoFixConflicts).toBe(myFn);
153
153
  });
154
- it('should call updateLogger', async () => {
154
+ it('should call setAccessToken', async () => {
155
155
  mockGithubConfigOptions({});
156
156
  await (0, options_1.getOptions)([], {});
157
- expect(logger.updateLogger).toHaveBeenCalledTimes(1);
157
+ expect(logger.setAccessToken).toHaveBeenCalledTimes(1);
158
158
  });
159
159
  it('should return options', async () => {
160
160
  mockGithubConfigOptions({
@@ -197,7 +197,6 @@ describe('getOptions', () => {
197
197
  targetBranchChoices: ['7.9', '8.0'],
198
198
  targetBranches: [],
199
199
  targetPRLabels: [],
200
- verbose: false,
201
200
  });
202
201
  });
203
202
  describe('sourceBranch', () => {
@@ -11,7 +11,7 @@ export declare type Result = {
11
11
  } | {
12
12
  status: 'failure';
13
13
  targetBranch: string;
14
- error: HandledError;
14
+ error: HandledError | Error;
15
15
  };
16
16
  export declare function runSequentially({ options, commits, targetBranches, gitConfigAuthor, }: {
17
17
  options: ValidConfigOptions;
@@ -25,7 +25,6 @@ async function runSequentially({ options, commits, targetBranches, gitConfigAuth
25
25
  });
26
26
  }
27
27
  catch (e) {
28
- process.exitCode = 1;
29
28
  results.push({
30
29
  targetBranch,
31
30
  status: 'failure',
@@ -1,15 +1,19 @@
1
1
  import { Commit } from './sourceCommit/parseSourceCommit';
2
2
  declare type ErrorContext = {
3
3
  code: 'merge-conflict-exception';
4
+ conflictingFiles: string[];
4
5
  commitsWithoutBackports: {
5
6
  formatted: string;
6
7
  commit: Commit;
7
8
  }[];
9
+ } | {
10
+ code: 'custom-exception';
11
+ message: string;
8
12
  } | {
9
13
  code: 'no-branches-exception' | 'abort-exception';
10
14
  };
11
15
  export declare class HandledError extends Error {
12
- errorContext?: ErrorContext;
13
- constructor(errorContext: ErrorContext | string);
16
+ errorContext: ErrorContext;
17
+ constructor(errorContextOrString: ErrorContext | string);
14
18
  }
15
19
  export {};