backport 7.3.2-beta.1 → 7.3.3

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 (44) hide show
  1. package/README.md +8 -0
  2. package/dist/backportRun.js +7 -0
  3. package/dist/entrypoint.cli.js +2 -2
  4. package/dist/entrypoint.module.d.ts +3 -0
  5. package/dist/entrypoint.module.js +19 -8
  6. package/dist/entrypoint.module.private.test.d.ts +1 -0
  7. package/dist/entrypoint.module.private.test.js +592 -0
  8. package/dist/options/ConfigOptions.d.ts +1 -0
  9. package/dist/options/cliArgs.d.ts +2 -0
  10. package/dist/options/cliArgs.js +8 -0
  11. package/dist/options/config/config.d.ts +1 -0
  12. package/dist/options/config/readConfigFile.d.ts +1 -0
  13. package/dist/options/options.d.ts +2 -0
  14. package/dist/options/options.js +5 -5
  15. package/dist/options/options.test.js +9 -2
  16. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +2 -2
  17. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +3 -2
  18. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +4 -0
  19. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +1 -1
  20. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +1 -1
  21. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +3 -3
  22. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +10 -4
  23. package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +12 -0
  24. package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +68 -0
  25. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -0
  26. package/dist/services/prompt.test.js +1 -1
  27. package/dist/services/prompts.js +4 -4
  28. package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +1 -1
  29. package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +1 -1
  30. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +39 -39
  31. package/dist/services/sourceCommit/parseSourceCommit.test.js +3 -3
  32. package/dist/test/e2e/cli/cli.private.test.js +3 -0
  33. package/dist/test/handleUnbackportedPullRequests.private.test.js +1 -1
  34. package/dist/ui/getCommits.js +9 -3
  35. package/dist/ui/getCommitsWithoutBackports.test.js +2 -2
  36. package/dist/ui/getTargetBranches.js +1 -1
  37. package/dist/ui/getTargetBranches.test.js +2 -2
  38. package/dist/utils/filterMissingCommits.d.ts +2 -0
  39. package/dist/utils/filterMissingCommits.js +7 -0
  40. package/dist/utils/filterUnmergedCommits.d.ts +2 -0
  41. package/dist/utils/filterUnmergedCommits.js +7 -0
  42. package/dist/utils/packageVersion.d.ts +1 -1
  43. package/dist/utils/packageVersion.js +1 -1
  44. package/package.json +3 -2
@@ -10,7 +10,7 @@ const commitFormatters_1 = require("../services/github/commitFormatters");
10
10
  const fetchCommitByPullNumber_1 = require("../services/github/v4/fetchCommits/fetchCommitByPullNumber");
11
11
  const fetchCommitBySha_1 = require("../services/github/v4/fetchCommits/fetchCommitBySha");
12
12
  const fetchCommitsByAuthor_1 = require("../services/github/v4/fetchCommits/fetchCommitsByAuthor");
13
- const fetchPullRequestBySearchQuery_1 = require("../services/github/v4/fetchCommits/fetchPullRequestBySearchQuery");
13
+ const fetchPullRequestsBySearchQuery_1 = require("../services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery");
14
14
  const prompts_1 = require("../services/prompts");
15
15
  const ora_1 = require("./ora");
16
16
  function getOraPersistsOption(question, answer) {
@@ -40,16 +40,22 @@ async function getCommits(options) {
40
40
  spinner.stopAndPersist(getOraPersistsOption('Select pull request', (0, commitFormatters_1.getFirstLine)(commit.sourceCommit.message)));
41
41
  return [commit];
42
42
  }
43
- if (options.ci) {
43
+ if (options.ci && !options.ls) {
44
44
  throw new HandledError_1.HandledError('When "--ci" flag is enabled either `--sha` or `--pr` must be specified');
45
45
  }
46
46
  spinner.text = options.prFilter
47
47
  ? 'Loading pull requests...'
48
48
  : `Loading commits from branch "${options.sourceBranch}"...`;
49
49
  const commitChoices = options.prFilter
50
- ? await (0, fetchPullRequestBySearchQuery_1.fetchPullRequestBySearchQuery)(options)
50
+ ? await (0, fetchPullRequestsBySearchQuery_1.fetchPullRequestsBySearchQuery)({
51
+ ...options,
52
+ prFilter: options.prFilter,
53
+ })
51
54
  : await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)(options);
52
55
  spinner.stop();
56
+ if (options.ls) {
57
+ return commitChoices;
58
+ }
53
59
  return (0, prompts_1.promptForCommits)({
54
60
  commitChoices,
55
61
  isMultipleChoice: options.multipleCommits,
@@ -95,9 +95,9 @@ describe('getCommitsWithoutBackports', () => {
95
95
  });
96
96
  expect((0, strip_ansi_1.default)(commitsWithoutBackports[0].formatted)).toEqual(' - First commit (#1) (backport missing)\n https://www.github.com/foo/bar/pull/123');
97
97
  });
98
- it('should display as missing if a backport is MISSING', async () => {
98
+ it('should display as missing if a backport is NOT_CREATED', async () => {
99
99
  const commitsWithoutBackports = await setupExpectedPullRequests({
100
- expectedTargetPullRequests: [{ state: 'MISSING', branch: '7.x' }],
100
+ expectedTargetPullRequests: [{ state: 'NOT_CREATED', branch: '7.x' }],
101
101
  });
102
102
  expect((0, strip_ansi_1.default)(commitsWithoutBackports[0].formatted)).toEqual(' - First commit (#1) (backport missing)\n https://www.github.com/foo/bar/pull/123');
103
103
  });
@@ -12,7 +12,7 @@ function getTargetBranches(options, commits) {
12
12
  // target branches from the first commit
13
13
  const missingTargetBranches = commits.length === 1
14
14
  ? commits[0].expectedTargetPullRequests
15
- .filter((pr) => pr.state === 'MISSING')
15
+ .filter((pr) => pr.state === 'NOT_CREATED' || pr.state === 'CLOSED')
16
16
  .map((pr) => pr.branch)
17
17
  : [];
18
18
  // automatically backport to specified target branches
@@ -101,7 +101,7 @@ describe('getTargetBranches', () => {
101
101
  expectedTargetPullRequests: [
102
102
  { branch: '7.2', state: 'MERGED' },
103
103
  { branch: '7.1', state: 'OPEN' },
104
- { branch: '7.x', state: 'MISSING' },
104
+ { branch: '7.x', state: 'NOT_CREATED' },
105
105
  ],
106
106
  },
107
107
  ];
@@ -142,7 +142,7 @@ describe('getTargetBranches', () => {
142
142
  },
143
143
  },
144
144
  sourceBranch: 'master',
145
- expectedTargetPullRequests: [{ branch: '7.x', state: 'MISSING' }],
145
+ expectedTargetPullRequests: [{ branch: '7.x', state: 'NOT_CREATED' }],
146
146
  },
147
147
  ];
148
148
  await (0, getTargetBranches_1.getTargetBranches)(options, commits);
@@ -0,0 +1,2 @@
1
+ import { Commit } from '../entrypoint.module';
2
+ export declare function filterUnmergedCommits(commit: Commit): boolean;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterUnmergedCommits = void 0;
4
+ function filterUnmergedCommits(commit) {
5
+ return commit.expectedTargetPullRequests.some((pr) => pr.state !== 'MERGED');
6
+ }
7
+ exports.filterUnmergedCommits = filterUnmergedCommits;
@@ -0,0 +1,2 @@
1
+ import { Commit } from '../entrypoint.module';
2
+ export declare function filterUnmergedCommits(commit: Commit): boolean;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterUnmergedCommits = void 0;
4
+ function filterUnmergedCommits(commit) {
5
+ return commit.expectedTargetPullRequests.some((pr) => pr.state !== 'MERGED');
6
+ }
7
+ exports.filterUnmergedCommits = filterUnmergedCommits;
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "7.3.2-beta.1";
1
+ export declare const PACKAGE_VERSION = "7.3.3";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PACKAGE_VERSION = void 0;
4
- exports.PACKAGE_VERSION = '7.3.2-beta.1';
4
+ exports.PACKAGE_VERSION = '7.3.3';
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "branches",
15
15
  "branching"
16
16
  ],
17
- "version": "7.3.2-beta.1",
17
+ "version": "7.3.3",
18
18
  "main": "./dist/entrypoint.module.js",
19
19
  "types": "dist/entrypoint.module.d.ts",
20
20
  "bin": {
@@ -33,7 +33,8 @@
33
33
  "test-all": "jest --config ./jest.config.all.js",
34
34
  "test-mutation": "jest --config ./jest.config.mutation.js",
35
35
  "test-private": "jest --config ./jest.config.private.js",
36
- "test": "jest"
36
+ "test": "jest",
37
+ "docker-run": "./docker/backport.sh"
37
38
  },
38
39
  "lint-staged": {
39
40
  "*.ts": [