backport 6.3.0-beta → 6.3.0-beta-2

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 (99) hide show
  1. package/dist/entrypoint.cli.e2e.private.test.d.ts +1 -0
  2. package/dist/entrypoint.cli.e2e.private.test.js +277 -0
  3. package/dist/entrypoint.cli.js +0 -0
  4. package/dist/entrypoint.cli.private.test.d.ts +1 -0
  5. package/dist/entrypoint.cli.private.test.js +46 -0
  6. package/dist/options/cliArgs.test.d.ts +1 -0
  7. package/dist/options/cliArgs.test.js +170 -0
  8. package/dist/options/config/config.test.d.ts +1 -0
  9. package/dist/options/config/config.test.js +32 -0
  10. package/dist/options/config/globalConfig.test.d.ts +1 -0
  11. package/dist/options/config/globalConfig.test.js +61 -0
  12. package/dist/options/config/projectConfig.test.d.ts +1 -0
  13. package/dist/options/config/projectConfig.test.js +109 -0
  14. package/dist/options/options.test.d.ts +1 -0
  15. package/dist/options/options.test.js +371 -0
  16. package/dist/runSequentially.test.d.ts +1 -0
  17. package/dist/runSequentially.test.js +218 -0
  18. package/dist/scripts/postinstall.test.d.ts +1 -0
  19. package/dist/scripts/postinstall.test.js +53 -0
  20. package/dist/services/env.test.d.ts +1 -0
  21. package/dist/services/env.test.js +21 -0
  22. package/dist/services/git.integration.test.d.ts +1 -0
  23. package/dist/services/git.integration.test.js +267 -0
  24. package/dist/services/git.test.d.ts +1 -0
  25. package/dist/services/git.test.js +518 -0
  26. package/dist/services/github/commitFormatters.test.d.ts +1 -0
  27. package/dist/services/github/commitFormatters.test.js +11 -0
  28. package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +1 -0
  29. package/dist/services/github/v3/addAssigneesToPullRequest.test.js +27 -0
  30. package/dist/services/github/v3/createPullRequest.test.d.ts +1 -0
  31. package/dist/services/github/v3/createPullRequest.test.js +325 -0
  32. package/dist/services/github/v3/createStatusComment.test.d.ts +1 -0
  33. package/dist/services/github/v3/createStatusComment.test.js +386 -0
  34. package/dist/services/github/v4/apiRequestV4.test.d.ts +1 -0
  35. package/dist/services/github/v4/apiRequestV4.test.js +82 -0
  36. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
  37. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
  38. package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +1 -0
  39. package/dist/services/github/v4/fetchAuthorId.private.test.js +28 -0
  40. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
  41. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +96 -0
  42. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
  43. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +143 -0
  44. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
  45. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +124 -0
  46. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
  47. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +200 -0
  48. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
  49. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +153 -0
  50. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
  51. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +102 -0
  52. package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +1 -0
  53. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +47 -0
  54. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
  55. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +52 -0
  56. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +4 -3
  57. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
  58. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +136 -0
  59. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +1 -0
  60. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +71 -0
  61. package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +2 -0
  62. package/dist/services/github/v4/mocks/commitsByAuthorMock.js +154 -0
  63. package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +1 -0
  64. package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +87 -0
  65. package/dist/services/prompt.test.d.ts +1 -0
  66. package/dist/services/prompt.test.js +134 -0
  67. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
  68. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +433 -0
  69. package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +1 -0
  70. package/dist/services/sourceCommit/parseSourceCommit.test.js +235 -0
  71. package/dist/test/ExecError.d.ts +16 -0
  72. package/dist/test/ExecError.js +15 -0
  73. package/dist/test/backport-e2e.mutation.test.d.ts +1 -0
  74. package/dist/test/backport-e2e.mutation.test.js +347 -0
  75. package/dist/test/handleUnbackportedPullRequests.private.test.d.ts +1 -0
  76. package/dist/test/handleUnbackportedPullRequests.private.test.js +57 -0
  77. package/dist/test/mockConfigFiles.d.ts +5 -0
  78. package/dist/test/mockConfigFiles.js +21 -0
  79. package/dist/test/mocks.d.ts +10 -0
  80. package/dist/test/mocks.js +23 -0
  81. package/dist/test/nockHelpers.d.ts +16 -0
  82. package/dist/test/nockHelpers.js +32 -0
  83. package/dist/test/private/getDevAccessToken.d.ts +1 -0
  84. package/dist/test/private/getDevAccessToken.js +25 -0
  85. package/dist/test/sandbox.d.ts +5 -0
  86. package/dist/test/sandbox.js +43 -0
  87. package/dist/test/setupFiles/automatic-mocks.d.ts +1 -0
  88. package/dist/test/setupFiles/automatic-mocks.js +59 -0
  89. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
  90. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +455 -0
  91. package/dist/ui/getCommitsWithoutBackports.test.d.ts +1 -0
  92. package/dist/ui/getCommitsWithoutBackports.test.js +311 -0
  93. package/dist/ui/getTargetBranches.test.d.ts +1 -0
  94. package/dist/ui/getTargetBranches.test.js +198 -0
  95. package/dist/ui/maybeSetupRepo.test.d.ts +1 -0
  96. package/dist/ui/maybeSetupRepo.test.js +204 -0
  97. package/dist/utils/excludeUndefined.test.d.ts +1 -0
  98. package/dist/utils/excludeUndefined.test.js +24 -0
  99. package/package.json +1 -1
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commitsByAuthorMock = void 0;
4
+ exports.commitsByAuthorMock = {
5
+ repository: {
6
+ ref: {
7
+ target: {
8
+ history: {
9
+ edges: [
10
+ {
11
+ node: {
12
+ repository: {
13
+ name: 'kibana',
14
+ owner: { login: 'elastic' },
15
+ },
16
+ committedDate: '2021-12-24T00:00:00Z',
17
+ sha: '2e63475c483f7844b0f2833bc57fdee32095bacb',
18
+ message: 'Add 👻',
19
+ associatedPullRequests: {
20
+ edges: [],
21
+ },
22
+ },
23
+ },
24
+ {
25
+ node: {
26
+ repository: {
27
+ name: 'kibana',
28
+ owner: { login: 'elastic' },
29
+ },
30
+ committedDate: '2021-12-23T00:00:00Z',
31
+ sha: 'f3b618b9421fdecdb36862f907afbdd6344b361d',
32
+ message: 'Add witch (#85)',
33
+ associatedPullRequests: {
34
+ edges: [
35
+ {
36
+ node: {
37
+ url: 'https://github.com/elastic/kibana/pull/85',
38
+ baseRefName: 'master',
39
+ labels: {
40
+ nodes: [{ name: 'my-label-b' }],
41
+ },
42
+ number: 85,
43
+ mergeCommit: {
44
+ sha: 'f3b618b9421fdecdb36862f907afbdd6344b361d',
45
+ message: 'Add witch (#85)',
46
+ },
47
+ timelineItems: {
48
+ edges: [],
49
+ },
50
+ },
51
+ },
52
+ ],
53
+ },
54
+ },
55
+ },
56
+ {
57
+ node: {
58
+ repository: {
59
+ name: 'kibana',
60
+ owner: { login: 'elastic' },
61
+ },
62
+ committedDate: '2021-12-22T00:00:00Z',
63
+ sha: '79cf18453ec32a4677009dcbab1c9c8c73fc14fe',
64
+ message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
65
+ associatedPullRequests: {
66
+ edges: [
67
+ {
68
+ node: {
69
+ url: 'https://github.com/elastic/kibana/pull/80',
70
+ labels: {
71
+ nodes: [{ name: 'v6.3.0' }],
72
+ },
73
+ baseRefName: 'master',
74
+ number: 80,
75
+ mergeCommit: {
76
+ sha: '79cf18453ec32a4677009dcbab1c9c8c73fc14fe',
77
+ message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
78
+ },
79
+ timelineItems: {
80
+ edges: [
81
+ {
82
+ node: {
83
+ targetPullRequest: {
84
+ __typename: 'PullRequest',
85
+ targetMergeCommit: {
86
+ sha: 'target-merge-commit-sha',
87
+ message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
88
+ },
89
+ repository: {
90
+ name: 'kibana',
91
+ owner: { login: 'elastic' },
92
+ },
93
+ url: 'https://github.com/elastic/kibana/pull/99',
94
+ title: 'some title',
95
+ state: 'MERGED',
96
+ number: 99,
97
+ baseRefName: '6.3',
98
+ commits: {
99
+ edges: [
100
+ {
101
+ node: {
102
+ targetCommit: {
103
+ sha: 'abc',
104
+ message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
105
+ },
106
+ },
107
+ },
108
+ ],
109
+ },
110
+ },
111
+ },
112
+ },
113
+ ],
114
+ },
115
+ },
116
+ },
117
+ ],
118
+ },
119
+ },
120
+ },
121
+ {
122
+ node: {
123
+ repository: {
124
+ name: 'kibana',
125
+ owner: { login: 'elastic' },
126
+ },
127
+ committedDate: '2021-12-21T00:00:00Z',
128
+ sha: '3827bbbaf39914eda4f02f6940189844375fd097',
129
+ message: 'Add backport config',
130
+ associatedPullRequests: {
131
+ edges: [],
132
+ },
133
+ },
134
+ },
135
+ {
136
+ node: {
137
+ repository: {
138
+ name: 'kibana',
139
+ owner: { login: 'elastic' },
140
+ },
141
+ committedDate: '2021-12-20T00:00:00Z',
142
+ sha: '5ea0da550ac191029459289d67f99ad7d310812b',
143
+ message: 'Initial commit',
144
+ associatedPullRequests: {
145
+ edges: [],
146
+ },
147
+ },
148
+ },
149
+ ],
150
+ },
151
+ },
152
+ },
153
+ },
154
+ };
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const throwOnInvalidAccessToken_1 = require("./throwOnInvalidAccessToken");
4
+ describe('throwOnInvalidAccessToken', () => {
5
+ describe('when status code is', () => {
6
+ it('should handle invalid access token', () => {
7
+ const error = {
8
+ axiosResponse: {
9
+ status: 401,
10
+ headers: {},
11
+ },
12
+ };
13
+ return expect(() => (0, throwOnInvalidAccessToken_1.throwOnInvalidAccessToken)({
14
+ repoOwner: 'elastic',
15
+ repoName: 'kibana',
16
+ error,
17
+ })).toThrowError('Please check your access token and make sure it is valid');
18
+ });
19
+ it('should handle SSO error', () => {
20
+ const error = {
21
+ axiosResponse: {
22
+ status: 200,
23
+ headers: { 'x-github-sso': 'required; url=https://ssourl.com' },
24
+ data: {
25
+ errors: [{ type: 'FORBIDDEN' }],
26
+ },
27
+ },
28
+ };
29
+ return expect(() => (0, throwOnInvalidAccessToken_1.throwOnInvalidAccessToken)({
30
+ repoOwner: 'elastic',
31
+ repoName: 'kibana',
32
+ error,
33
+ })).toThrowErrorMatchingSnapshot();
34
+ });
35
+ it('should handle non-existing repo', () => {
36
+ const error = {
37
+ axiosResponse: {
38
+ status: 200,
39
+ headers: {
40
+ 'x-oauth-scopes': 'a,b,c',
41
+ 'x-accepted-oauth-scopes': 'a,b,c',
42
+ },
43
+ data: {
44
+ errors: [{ type: 'NOT_FOUND', path: ['repository'] }],
45
+ },
46
+ },
47
+ };
48
+ return expect(() => (0, throwOnInvalidAccessToken_1.throwOnInvalidAccessToken)({
49
+ repoOwner: 'elastic',
50
+ repoName: 'kibana',
51
+ error,
52
+ })).toThrowError(`The repository "elastic/kibana" doesn't exist`);
53
+ });
54
+ it('should handle insufficient permissions (oauth scopes)', () => {
55
+ const error = {
56
+ axiosResponse: {
57
+ status: 200,
58
+ headers: {
59
+ 'x-oauth-scopes': 'a,b',
60
+ 'x-accepted-oauth-scopes': 'a,b,c',
61
+ },
62
+ data: {
63
+ errors: [{ type: 'NOT_FOUND', path: ['repository'] }],
64
+ },
65
+ },
66
+ };
67
+ return expect(() => (0, throwOnInvalidAccessToken_1.throwOnInvalidAccessToken)({
68
+ repoOwner: 'elastic',
69
+ repoName: 'kibana',
70
+ error,
71
+ })).toThrowErrorMatchingSnapshot();
72
+ });
73
+ it('should not handle unknown cases', () => {
74
+ const error = {
75
+ axiosResponse: {
76
+ status: 500,
77
+ headers: {},
78
+ },
79
+ };
80
+ return expect((0, throwOnInvalidAccessToken_1.throwOnInvalidAccessToken)({
81
+ repoOwner: 'elastic',
82
+ repoName: 'kibana',
83
+ error,
84
+ })).toBe(undefined);
85
+ });
86
+ });
87
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const strip_ansi_1 = __importDefault(require("strip-ansi"));
7
+ const prompts_1 = require("./prompts");
8
+ describe('prompt', () => {
9
+ describe('getChoicesForCommitPrompt', () => {
10
+ it('should display status badges via `expectedTargetPullRequests`', () => {
11
+ const commits = [
12
+ {
13
+ sourceBranch: 'master',
14
+ sourceCommit: {
15
+ committedDate: '1',
16
+ sha: 'ae9d51b7fe3ee6f30d0d196c782e0dcabb7ac5ff',
17
+ message: '[APM] Remove log-log descriptions from correlation charts (#119700)',
18
+ },
19
+ sourcePullRequest: {
20
+ number: 119700,
21
+ url: 'foo',
22
+ mergeCommit: {
23
+ sha: 'ae9d51b7fe3ee6f30d0d196c782e0dcabb7ac5ff',
24
+ message: '[APM] Remove log-log descriptions from correlation charts (#119700)',
25
+ },
26
+ },
27
+ expectedTargetPullRequests: [
28
+ { number: 120178, branch: '8.0', state: 'MERGED' },
29
+ { number: 120179, branch: '7.16', state: 'MERGED' },
30
+ { number: 120179, branch: '7.15', state: 'MISSING' },
31
+ ],
32
+ },
33
+ ];
34
+ const choices = (0, prompts_1.getChoicesForCommitPrompt)(commits, false).map(({ name, short }) => ({ name: (0, strip_ansi_1.default)(name), short }));
35
+ expect(choices).toEqual([
36
+ {
37
+ name: '1. [APM] Remove log-log descriptions from correlation charts (#119700) 8.0, 7.16, 7.15',
38
+ short: '#119700 (ae9d51b7)',
39
+ },
40
+ ]);
41
+ });
42
+ it('should list choices', () => {
43
+ const commits = [
44
+ {
45
+ sourceBranch: 'master',
46
+ sourceCommit: {
47
+ committedDate: '',
48
+ sha: 'b1b491959dab47aeb83c88ee2accb2db46d23793',
49
+ message: '[APM] Prefer service.name for logs correlation (#120694)',
50
+ },
51
+ sourcePullRequest: {
52
+ number: 120694,
53
+ url: 'foo',
54
+ mergeCommit: {
55
+ sha: 'b1b491959dab47aeb83c88ee2accb2db46d23793',
56
+ message: '[APM] Prefer service.name for logs correlation (#120694)',
57
+ },
58
+ },
59
+ expectedTargetPullRequests: [],
60
+ },
61
+ {
62
+ sourceBranch: 'master',
63
+ sourceCommit: {
64
+ committedDate: '',
65
+ sha: 'b1bb4a93959f19a653b9cfb207a5c6acb6559482',
66
+ message: '[APM] Disable telemetry in agent config endpoint (#120106)',
67
+ },
68
+ sourcePullRequest: {
69
+ number: 120106,
70
+ url: 'foo',
71
+ mergeCommit: {
72
+ sha: 'b1bb4a93959f19a653b9cfb207a5c6acb6559482',
73
+ message: '[APM] Disable telemetry in agent config endpoint (#120106)',
74
+ },
75
+ },
76
+ expectedTargetPullRequests: [],
77
+ },
78
+ {
79
+ sourceBranch: 'master',
80
+ sourceCommit: {
81
+ committedDate: '',
82
+ sha: '434f6e6a88faf24dc1ea41f9f726db78e46355a7',
83
+ message: '[APM] Remove index_pattern.json and add custom field formatters (#119915)',
84
+ },
85
+ sourcePullRequest: {
86
+ number: 119915,
87
+ url: 'foo',
88
+ mergeCommit: {
89
+ sha: '434f6e6a88faf24dc1ea41f9f726db78e46355a7',
90
+ message: '[APM] Remove index_pattern.json and add custom field formatters (#119915)',
91
+ },
92
+ },
93
+ expectedTargetPullRequests: [],
94
+ },
95
+ {
96
+ sourceBranch: 'master',
97
+ sourceCommit: {
98
+ committedDate: '',
99
+ sha: 'ae9d51b7fe3ee6f30d0d196c782e0dcabb7ac5ff',
100
+ message: '[APM] Remove log-log descriptions from correlation charts (#119700)',
101
+ },
102
+ sourcePullRequest: {
103
+ number: 119700,
104
+ url: 'foo',
105
+ mergeCommit: {
106
+ sha: 'ae9d51b7fe3ee6f30d0d196c782e0dcabb7ac5ff',
107
+ message: '[APM] Remove log-log descriptions from correlation charts (#119700)',
108
+ },
109
+ },
110
+ expectedTargetPullRequests: [],
111
+ },
112
+ ];
113
+ const choices = (0, prompts_1.getChoicesForCommitPrompt)(commits, false).map(({ name, short }) => ({ name: (0, strip_ansi_1.default)(name), short }));
114
+ expect(choices).toEqual([
115
+ {
116
+ name: '1. [APM] Prefer service.name for logs correlation (#120694) ',
117
+ short: '#120694 (b1b49195)',
118
+ },
119
+ {
120
+ name: '2. [APM] Disable telemetry in agent config endpoint (#120106) ',
121
+ short: '#120106 (b1bb4a93)',
122
+ },
123
+ {
124
+ name: '3. [APM] Remove index_pattern.json and add custom field formatters (#119915) ',
125
+ short: '#119915 (434f6e6a)',
126
+ },
127
+ {
128
+ name: '4. [APM] Remove log-log descriptions from correlation charts (#119700) ',
129
+ short: '#119700 (ae9d51b7)',
130
+ },
131
+ ]);
132
+ });
133
+ });
134
+ });