backport 7.0.1-beta.2 → 7.2.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 (163) hide show
  1. package/dist/backportRun.d.ts +1 -0
  2. package/dist/backportRun.js +3 -2
  3. package/dist/entrypoint.cli.js +12 -1
  4. package/dist/entrypoint.module.d.ts +4 -3
  5. package/dist/entrypoint.module.js +2 -7
  6. package/dist/options/ConfigOptions.d.ts +1 -1
  7. package/dist/options/cliArgs.d.ts +2 -1
  8. package/dist/options/cliArgs.js +4 -0
  9. package/dist/options/config/config.d.ts +1 -1
  10. package/dist/options/config/readConfigFile.d.ts +2 -2
  11. package/dist/options/options.d.ts +3 -6
  12. package/dist/runSequentially.js +1 -0
  13. package/dist/services/HandledError.js +3 -1
  14. package/dist/services/git.d.ts +2 -0
  15. package/dist/services/git.js +47 -10
  16. package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +1 -1
  17. package/dist/services/github/v3/addAssigneesToPullRequest.js +3 -6
  18. package/dist/services/github/v3/addLabelsToPullRequest.d.ts +1 -1
  19. package/dist/services/github/v3/addLabelsToPullRequest.js +3 -6
  20. package/dist/services/github/v3/addReviewersToPullRequest.d.ts +1 -1
  21. package/dist/services/github/v3/addReviewersToPullRequest.js +3 -6
  22. package/dist/services/github/v3/createPullRequest.js +2 -5
  23. package/dist/services/github/v3/createStatusComment.js +1 -1
  24. package/dist/services/github/v4/FetchPullRequestId.js +5 -1
  25. package/dist/services/github/v4/apiRequestV4.d.ts +7 -4
  26. package/dist/services/github/v4/apiRequestV4.js +22 -21
  27. package/dist/services/github/v4/disablePullRequestAutoMerge.js +5 -1
  28. package/dist/services/github/v4/enablePullRequestAutoMerge.js +4 -3
  29. package/dist/services/github/v4/fetchAuthorId.js +5 -1
  30. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +0 -1
  31. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +24 -13
  32. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +0 -1
  33. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +24 -13
  34. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +0 -1
  35. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +20 -10
  36. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +20 -9
  37. package/dist/services/github/v4/fetchExistingPullRequest.js +5 -1
  38. package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +5 -1
  39. package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +1 -1
  40. package/dist/services/github/v4/fetchRemoteProjectConfig.js +13 -20
  41. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -5
  42. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +12 -66
  43. package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +3 -16
  44. package/dist/services/github/v4/getOptionsFromGithub/query.js +9 -19
  45. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +5 -1
  46. package/dist/services/github/v4/throwOnInvalidAccessToken.js +6 -6
  47. package/dist/services/logger.d.ts +5 -5
  48. package/dist/services/logger.js +24 -23
  49. package/dist/services/remoteConfig.d.ts +20 -0
  50. package/dist/services/remoteConfig.js +52 -0
  51. package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +4 -1
  52. package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +5 -1
  53. package/dist/services/sourceCommit/getMockSourceCommit.d.ts +4 -0
  54. package/dist/services/sourceCommit/getMockSourceCommit.js +21 -6
  55. package/dist/services/sourceCommit/parseSourceCommit.d.ts +3 -4
  56. package/dist/services/sourceCommit/parseSourceCommit.js +73 -77
  57. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +16 -22
  58. package/dist/ui/getCommits.js +8 -6
  59. package/dist/ui/maybeSetupRepo.js +7 -14
  60. package/dist/ui/ora.d.ts +9 -0
  61. package/dist/ui/ora.js +21 -0
  62. package/dist/utils/packageVersion.d.ts +1 -1
  63. package/dist/utils/packageVersion.js +1 -1
  64. package/package.json +10 -10
  65. package/yarn.lock +121 -114
  66. package/dist/entrypoint.cli.e2e.private.test.d.ts +0 -1
  67. package/dist/entrypoint.cli.e2e.private.test.js +0 -319
  68. package/dist/entrypoint.cli.private.test.d.ts +0 -1
  69. package/dist/entrypoint.cli.private.test.js +0 -46
  70. package/dist/options/cliArgs.test.d.ts +0 -1
  71. package/dist/options/cliArgs.test.js +0 -182
  72. package/dist/options/config/config.test.d.ts +0 -1
  73. package/dist/options/config/config.test.js +0 -32
  74. package/dist/options/config/globalConfig.test.d.ts +0 -1
  75. package/dist/options/config/globalConfig.test.js +0 -61
  76. package/dist/options/config/projectConfig.test.d.ts +0 -1
  77. package/dist/options/config/projectConfig.test.js +0 -109
  78. package/dist/options/options.test.d.ts +0 -1
  79. package/dist/options/options.test.js +0 -386
  80. package/dist/runSequentially.test.d.ts +0 -1
  81. package/dist/runSequentially.test.js +0 -218
  82. package/dist/scripts/postinstall.test.d.ts +0 -1
  83. package/dist/scripts/postinstall.test.js +0 -53
  84. package/dist/services/env.test.d.ts +0 -1
  85. package/dist/services/env.test.js +0 -21
  86. package/dist/services/git.integration.test.d.ts +0 -1
  87. package/dist/services/git.integration.test.js +0 -267
  88. package/dist/services/git.test.d.ts +0 -1
  89. package/dist/services/git.test.js +0 -518
  90. package/dist/services/github/commitFormatters.test.d.ts +0 -1
  91. package/dist/services/github/commitFormatters.test.js +0 -11
  92. package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +0 -1
  93. package/dist/services/github/v3/addAssigneesToPullRequest.test.js +0 -27
  94. package/dist/services/github/v3/createPullRequest.test.d.ts +0 -1
  95. package/dist/services/github/v3/createPullRequest.test.js +0 -325
  96. package/dist/services/github/v3/createStatusComment.test.d.ts +0 -1
  97. package/dist/services/github/v3/createStatusComment.test.js +0 -386
  98. package/dist/services/github/v3/index.d.ts +0 -1
  99. package/dist/services/github/v3/index.js +0 -61
  100. package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
  101. package/dist/services/github/v4/apiRequestV4.test.js +0 -82
  102. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +0 -1
  103. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
  104. package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +0 -1
  105. package/dist/services/github/v4/fetchAuthorId.private.test.js +0 -28
  106. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +0 -1
  107. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -96
  108. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
  109. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -143
  110. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
  111. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -124
  112. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
  113. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -200
  114. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
  115. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -153
  116. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
  117. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +0 -102
  118. package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +0 -1
  119. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -47
  120. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +0 -1
  121. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +0 -52
  122. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +0 -1
  123. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -136
  124. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +0 -1
  125. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +0 -71
  126. package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +0 -2
  127. package/dist/services/github/v4/mocks/commitsByAuthorMock.js +0 -154
  128. package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +0 -1
  129. package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +0 -87
  130. package/dist/services/prompt.test.d.ts +0 -1
  131. package/dist/services/prompt.test.js +0 -134
  132. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +0 -1
  133. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +0 -433
  134. package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +0 -1
  135. package/dist/services/sourceCommit/parseSourceCommit.test.js +0 -235
  136. package/dist/test/ExecError.d.ts +0 -16
  137. package/dist/test/ExecError.js +0 -15
  138. package/dist/test/backport-e2e.mutation.test.d.ts +0 -1
  139. package/dist/test/backport-e2e.mutation.test.js +0 -347
  140. package/dist/test/handleUnbackportedPullRequests.private.test.d.ts +0 -1
  141. package/dist/test/handleUnbackportedPullRequests.private.test.js +0 -57
  142. package/dist/test/mockConfigFiles.d.ts +0 -5
  143. package/dist/test/mockConfigFiles.js +0 -21
  144. package/dist/test/mocks.d.ts +0 -10
  145. package/dist/test/mocks.js +0 -23
  146. package/dist/test/nockHelpers.d.ts +0 -16
  147. package/dist/test/nockHelpers.js +0 -32
  148. package/dist/test/private/getDevAccessToken.d.ts +0 -2
  149. package/dist/test/private/getDevAccessToken.js +0 -12
  150. package/dist/test/sandbox.d.ts +0 -5
  151. package/dist/test/sandbox.js +0 -43
  152. package/dist/test/setupFiles/automatic-mocks.d.ts +0 -1
  153. package/dist/test/setupFiles/automatic-mocks.js +0 -63
  154. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
  155. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +0 -455
  156. package/dist/ui/getCommitsWithoutBackports.test.d.ts +0 -1
  157. package/dist/ui/getCommitsWithoutBackports.test.js +0 -311
  158. package/dist/ui/getTargetBranches.test.d.ts +0 -1
  159. package/dist/ui/getTargetBranches.test.js +0 -198
  160. package/dist/ui/maybeSetupRepo.test.d.ts +0 -1
  161. package/dist/ui/maybeSetupRepo.test.js +0 -204
  162. package/dist/utils/excludeUndefined.test.d.ts +0 -1
  163. package/dist/utils/excludeUndefined.test.js +0 -24
@@ -1,204 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- const promises_1 = require("fs/promises");
26
- const os_1 = __importDefault(require("os"));
27
- const del_1 = __importDefault(require("del"));
28
- const childProcess = __importStar(require("../services/child-process-promisified"));
29
- const git = __importStar(require("../services/git"));
30
- const mocks_1 = require("../test/mocks");
31
- const maybeSetupRepo_1 = require("./maybeSetupRepo");
32
- const fs = { stat: promises_1.stat };
33
- describe('maybeSetupRepo', () => {
34
- let execSpy;
35
- beforeEach(() => {
36
- jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
37
- execSpy = jest
38
- .spyOn(childProcess, 'exec')
39
- .mockResolvedValue({ stderr: '', stdout: '' });
40
- });
41
- afterEach(() => {
42
- jest.restoreAllMocks();
43
- });
44
- describe('if an error occurs while cloning', () => {
45
- it('should delete repo', async () => {
46
- expect.assertions(2);
47
- execSpy = jest
48
- .spyOn(childProcess, 'execAsCallback')
49
- .mockImplementation((cmd) => {
50
- if (cmd.startsWith('git clone')) {
51
- throw new Error('Simulated git clone failure');
52
- }
53
- throw new Error('unknown error');
54
- });
55
- await expect((0, maybeSetupRepo_1.maybeSetupRepo)({
56
- repoName: 'kibana',
57
- repoOwner: 'elastic',
58
- })).rejects.toThrowError('Simulated git clone failure');
59
- expect(del_1.default).toHaveBeenCalledWith('/myHomeDir/.backport/repositories/elastic/kibana');
60
- });
61
- });
62
- describe('while cloning the repo', () => {
63
- it('updates the progress', async () => {
64
- let onCloneComplete;
65
- let dataHandler;
66
- const oraMock = (0, mocks_1.getOraMock)();
67
- const spinnerTextSpy = jest.spyOn(oraMock, 'text', 'set');
68
- const spinnerSuccessSpy = jest.spyOn(oraMock, 'succeed');
69
- jest
70
- .spyOn(git, 'getSourceRepoPath')
71
- .mockResolvedValue('/path/to/source/repo');
72
- jest
73
- .spyOn(childProcess, 'execAsCallback')
74
- //@ts-expect-error
75
- .mockImplementation((cmdString, cmdOptions, onComplete) => {
76
- // callback should be called to finalize the operation
77
- if (onComplete) {
78
- //@ts-expect-error
79
- onCloneComplete = onComplete;
80
- }
81
- return {
82
- stderr: {
83
- on: (name, handler) => {
84
- dataHandler = handler;
85
- },
86
- },
87
- };
88
- });
89
- setTimeout(() => {
90
- dataHandler('Receiving objects: 1%');
91
- dataHandler('Receiving objects: 10%');
92
- dataHandler('Receiving objects: 20%');
93
- dataHandler('Receiving objects: 100%');
94
- dataHandler('Updating files: 1%');
95
- dataHandler('Updating files: 10%');
96
- dataHandler('Updating files: 20%');
97
- dataHandler('Updating files: 100%');
98
- onCloneComplete();
99
- }, 50);
100
- await (0, maybeSetupRepo_1.maybeSetupRepo)({
101
- repoName: 'kibana',
102
- repoOwner: 'elastic',
103
- });
104
- expect(spinnerTextSpy.mock.calls.map((call) => call[0]))
105
- .toMatchInlineSnapshot(`
106
- Array [
107
- "0% Cloning repository from /path/to/source/repo (one-time operation)",
108
- "1% Cloning repository from /path/to/source/repo (one-time operation)",
109
- "9% Cloning repository from /path/to/source/repo (one-time operation)",
110
- "18% Cloning repository from /path/to/source/repo (one-time operation)",
111
- "90% Cloning repository from /path/to/source/repo (one-time operation)",
112
- "90% Cloning repository from /path/to/source/repo (one-time operation)",
113
- "91% Cloning repository from /path/to/source/repo (one-time operation)",
114
- "92% Cloning repository from /path/to/source/repo (one-time operation)",
115
- "100% Cloning repository from /path/to/source/repo (one-time operation)",
116
- ]
117
- `);
118
- expect(spinnerSuccessSpy).toHaveBeenCalledWith('100% Cloning repository from /path/to/source/repo (one-time operation)');
119
- });
120
- });
121
- describe('if repo already exists', () => {
122
- beforeEach(() => {
123
- // @ts-expect-error
124
- jest.spyOn(fs, 'stat').mockResolvedValue({ isDirectory: () => true });
125
- jest
126
- .spyOn(childProcess, 'execAsCallback')
127
- //@ts-expect-error
128
- .mockImplementation((cmdString, cmdOptions, callback) => {
129
- //@ts-expect-error
130
- callback();
131
- return {
132
- stderr: { on: () => null },
133
- };
134
- });
135
- });
136
- it('should re-create remotes for both source repo and fork', async () => {
137
- await (0, maybeSetupRepo_1.maybeSetupRepo)({
138
- accessToken: 'myAccessToken',
139
- authenticatedUsername: 'sqren_authenticated',
140
- repoName: 'kibana',
141
- repoOwner: 'elastic',
142
- });
143
- expect(execSpy.mock.calls.map(([cmd]) => cmd)).toEqual([
144
- 'git remote --verbose',
145
- 'git remote rm origin',
146
- 'git remote rm sqren_authenticated',
147
- 'git remote add sqren_authenticated https://x-access-token:myAccessToken@github.com/sqren_authenticated/kibana.git',
148
- 'git remote rm elastic',
149
- 'git remote add elastic https://x-access-token:myAccessToken@github.com/elastic/kibana.git',
150
- ]);
151
- });
152
- });
153
- describe('if repo does not exists locally', () => {
154
- beforeEach(() => {
155
- // @ts-expect-error
156
- jest.spyOn(fs, 'stat').mockResolvedValue({ isDirectory: () => true });
157
- jest
158
- .spyOn(childProcess, 'execAsCallback')
159
- //@ts-expect-error
160
- .mockImplementation((cmdString, cmdOptions, callback) => {
161
- //@ts-expect-error
162
- callback();
163
- return {
164
- stderr: { on: () => null },
165
- };
166
- });
167
- });
168
- it('should clone it from github.com', async () => {
169
- await (0, maybeSetupRepo_1.maybeSetupRepo)({
170
- accessToken: 'myAccessToken',
171
- gitHostname: 'github.com',
172
- repoName: 'kibana',
173
- repoOwner: 'elastic',
174
- });
175
- expect(childProcess.execAsCallback).toHaveBeenCalledWith('git clone https://x-access-token:myAccessToken@github.com/elastic/kibana.git /myHomeDir/.backport/repositories/elastic/kibana --progress', expect.any(Object), expect.any(Function));
176
- });
177
- });
178
- describe('if repo does exist locally', () => {
179
- beforeEach(() => {
180
- // @ts-expect-error
181
- jest.spyOn(fs, 'stat').mockResolvedValue({ isDirectory: () => true });
182
- jest
183
- .spyOn(git, 'getSourceRepoPath')
184
- .mockResolvedValue('/path/to/source/repo');
185
- jest
186
- .spyOn(childProcess, 'execAsCallback')
187
- //@ts-expect-error
188
- .mockImplementation((cmdString, cmdOptions, callback) => {
189
- //@ts-expect-error
190
- callback();
191
- return {
192
- stderr: { on: () => null },
193
- };
194
- });
195
- });
196
- it('should clone it from local folder', async () => {
197
- await (0, maybeSetupRepo_1.maybeSetupRepo)({
198
- repoName: 'kibana',
199
- repoOwner: 'elastic',
200
- });
201
- expect(childProcess.execAsCallback).toHaveBeenCalledWith('git clone /path/to/source/repo /myHomeDir/.backport/repositories/elastic/kibana --progress', expect.any(Object), expect.any(Function));
202
- });
203
- });
204
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const excludeUndefined_1 = require("./excludeUndefined");
4
- describe('excludeUndefined', () => {
5
- it('removes undefined values', () => {
6
- expect((0, excludeUndefined_1.excludeUndefined)({
7
- foo: 'foo',
8
- bar: undefined,
9
- baz: null,
10
- })).toEqual({ foo: 'foo', baz: null });
11
- });
12
- it('has the correct types after merging', () => {
13
- const obj = (0, excludeUndefined_1.excludeUndefined)({
14
- foo: 'foo',
15
- bar: undefined,
16
- baz: null,
17
- });
18
- const res = {
19
- bar: 'bar',
20
- ...obj,
21
- };
22
- expect(res).toEqual({ bar: 'bar', foo: 'foo', baz: null });
23
- });
24
- });