backport 7.2.0 → 7.3.0-beta.1

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 (54) hide show
  1. package/README.md +10 -5
  2. package/dist/entrypoint.cli.d.ts +0 -1
  3. package/dist/entrypoint.cli.js +0 -1
  4. package/dist/entrypoint.cli.private.test.js +1 -0
  5. package/dist/options/ConfigOptions.d.ts +2 -0
  6. package/dist/options/config/config.d.ts +2 -0
  7. package/dist/options/config/readConfigFile.d.ts +2 -0
  8. package/dist/options/options.d.ts +2 -0
  9. package/dist/runSequentially.js +2 -2
  10. package/dist/services/git.d.ts +11 -2
  11. package/dist/services/git.integration.test.js +12 -46
  12. package/dist/services/git.js +31 -15
  13. package/dist/services/git.test.js +12 -1
  14. package/dist/services/github/v3/createPullRequest.test.js +52 -0
  15. package/dist/services/github/v3/createStatusComment.test.js +12 -2
  16. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +1 -0
  17. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +1 -0
  18. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +1 -0
  19. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +5 -0
  20. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +2 -0
  21. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +2 -0
  22. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +1 -0
  23. package/dist/services/github/v4/mocks/commitsByAuthorMock.js +20 -0
  24. package/dist/services/prompt.test.js +5 -0
  25. package/dist/services/sourceCommit/getMockSourceCommit.js +1 -0
  26. package/dist/services/sourceCommit/parseSourceCommit.d.ts +5 -0
  27. package/dist/services/sourceCommit/parseSourceCommit.js +6 -0
  28. package/dist/services/sourceCommit/parseSourceCommit.test.js +1 -0
  29. package/dist/test/e2e/cli/cli.private.test.d.ts +1 -0
  30. package/dist/test/e2e/cli/cli.private.test.js +215 -0
  31. package/dist/test/e2e/cli/different-merge-strategies.private.test.d.ts +1 -0
  32. package/dist/test/e2e/cli/different-merge-strategies.private.test.js +108 -0
  33. package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.d.ts +1 -0
  34. package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +49 -0
  35. package/dist/test/e2e/cli/runBackportViaCli.d.ts +5 -0
  36. package/dist/test/e2e/cli/runBackportViaCli.js +53 -0
  37. package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.d.ts +1 -0
  38. package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +73 -0
  39. package/dist/test/e2e/module.e2e.mutation.test.d.ts +1 -0
  40. package/dist/test/e2e/module.e2e.mutation.test.js +369 -0
  41. package/dist/test/e2e/module.e2e.private.test.js +6 -0
  42. package/dist/test/handleUnbackportedPullRequests.private.test.js +1 -0
  43. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +3 -3
  44. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +24 -14
  45. package/dist/ui/getCommitsWithoutBackports.test.js +20 -0
  46. package/dist/ui/getTargetBranches.test.js +2 -0
  47. package/dist/ui/setupRepo.d.ts +3 -0
  48. package/dist/ui/setupRepo.js +88 -0
  49. package/dist/ui/setupRepo.test.d.ts +1 -0
  50. package/dist/ui/setupRepo.test.js +288 -0
  51. package/dist/utils/packageVersion.d.ts +1 -1
  52. package/dist/utils/packageVersion.js +1 -1
  53. package/package.json +6 -6
  54. package/yarn.lock +3 -3
package/README.md CHANGED
@@ -29,6 +29,10 @@ After installation you should add an access token to the [global config](https:/
29
29
 
30
30
  ## Quick start
31
31
 
32
+ ```
33
+ npm install backport
34
+ ```
35
+
32
36
  Add a [project config](https://github.com/sqren/backport/blob/master/docs/configuration.md#project-config-backportrcjson) to the root of your repository:
33
37
 
34
38
  ```js
@@ -48,10 +52,12 @@ Add a [project config](https://github.com/sqren/backport/blob/master/docs/config
48
52
  }
49
53
  ```
50
54
 
51
- Install locally:
52
-
53
- ```
54
- npm install backport
55
+ Add personal access token to [global config](https://github.com/sqren/backport/blob/master/docs/configuration.md#global-config-backportconfigjson):
56
+ ```js
57
+ // ~/.backport/config.json
58
+ {
59
+ "accessToken": "ghp_very_secret"
60
+ }
55
61
  ```
56
62
 
57
63
  Run:
@@ -265,6 +271,5 @@ See [CONTRIBUTING.md](https://github.com/sqren/backport/blob/master/CONTRIBUTING
265
271
  [1]: https://git-scm.com/docs/git-cherry-pick#Documentation/git-cherry-pick.txt--x
266
272
  [2]: https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax
267
273
 
268
- [![Build Status](https://travis-ci.com/sqren/backport.svg?branch=master)](https://app.travis-ci.com/github/sqren/backport)
269
274
  [![NPM version](https://img.shields.io/npm/v/backport.svg)](https://www.npmjs.com/package/backport)
270
275
  [![Coverage Status](https://coveralls.io/repos/github/sqren/backport/badge.svg?branch=master)](https://coveralls.io/github/sqren/backport?branch=master)
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
1
  export {};
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
  "use strict";
3
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -13,6 +13,7 @@ describe('entrypoint.module', () => {
13
13
  });
14
14
  const expectedCommits = [
15
15
  {
16
+ author: { email: 'sorenlouv@gmail.com', name: 'Søren Louv-Jansen' },
16
17
  sourceCommit: {
17
18
  committedDate: '2020-08-15T10:44:04Z',
18
19
  message: 'Add family emoji (#2)',
@@ -30,6 +30,8 @@ declare type Options = Partial<{
30
30
  gitHostname: string;
31
31
  githubApiBaseUrlV3: string;
32
32
  githubApiBaseUrlV4: string;
33
+ gitUserEmail: string;
34
+ gitUserName: string;
33
35
  logFilePath: string;
34
36
  maxNumber: number;
35
37
  multiple: boolean;
@@ -30,6 +30,8 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
30
30
  gitHostname?: string | undefined;
31
31
  githubApiBaseUrlV3?: string | undefined;
32
32
  githubApiBaseUrlV4?: string | undefined;
33
+ gitUserEmail?: string | undefined;
34
+ gitUserName?: string | undefined;
33
35
  logFilePath?: string | undefined;
34
36
  maxNumber?: number | undefined;
35
37
  multiple?: boolean | undefined;
@@ -52,5 +52,7 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
52
52
  targetBranch: string;
53
53
  }) => boolean | Promise<boolean>) | undefined;
54
54
  backportBinary?: string | undefined;
55
+ gitUserEmail?: string | undefined;
56
+ gitUserName?: string | undefined;
55
57
  branchLabelMapping?: Record<string, string> | undefined;
56
58
  };
@@ -52,6 +52,8 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
52
52
  targetBranch: string;
53
53
  }) => boolean | Promise<boolean>) | undefined;
54
54
  backportBinary: string;
55
+ gitUserEmail?: string | undefined;
56
+ gitUserName?: string | undefined;
55
57
  multiple?: boolean | undefined;
56
58
  help?: boolean | undefined;
57
59
  version?: boolean | undefined;
@@ -4,10 +4,10 @@ exports.runSequentially = void 0;
4
4
  const logger_1 = require("./services/logger");
5
5
  const sequentially_1 = require("./services/sequentially");
6
6
  const cherrypickAndCreateTargetPullRequest_1 = require("./ui/cherrypickAndCreateTargetPullRequest");
7
- const maybeSetupRepo_1 = require("./ui/maybeSetupRepo");
7
+ const setupRepo_1 = require("./ui/setupRepo");
8
8
  async function runSequentially({ options, commits, targetBranches, }) {
9
9
  logger_1.logger.verbose('Backport options', options);
10
- await (0, maybeSetupRepo_1.maybeSetupRepo)(options);
10
+ await (0, setupRepo_1.setupRepo)(options, commits);
11
11
  const results = [];
12
12
  await (0, sequentially_1.sequentially)(targetBranches, async (targetBranch) => {
13
13
  logger_1.logger.info(`Backporting ${JSON.stringify(commits)} to ${targetBranch}`);
@@ -21,7 +21,7 @@ export declare function getRepoInfoFromGitRemotes({ cwd }: {
21
21
  repoOwner: string;
22
22
  repoName: string;
23
23
  }[]>;
24
- export declare function getGitProjectRoot(dir: string): Promise<string | undefined>;
24
+ export declare function getGitProjectRootPath(dir: string): Promise<string | undefined>;
25
25
  export declare function getIsCommitInBranch(options: ValidConfigOptions, commitSha: string): Promise<boolean>;
26
26
  export declare function deleteRemote(options: ValidConfigOptions, remoteName: string): Promise<void>;
27
27
  export declare function addRemote(options: ValidConfigOptions, remoteName: string): Promise<void>;
@@ -47,6 +47,15 @@ export declare function setCommitAuthor(options: ValidConfigOptions, author: str
47
47
  stdout: string;
48
48
  stderr: string;
49
49
  }>;
50
+ export declare function getGitConfig({ dir, key, }: {
51
+ dir: string;
52
+ key: 'user.name' | 'user.email';
53
+ }): Promise<string | undefined>;
54
+ export declare function setGitConfig({ dir, key, value, }: {
55
+ dir: string;
56
+ key: 'user.name' | 'user.email';
57
+ value: string;
58
+ }): Promise<void>;
50
59
  export declare function createBackportBranch({ options, targetBranch, backportBranch, }: {
51
60
  options: ValidConfigOptions;
52
61
  targetBranch: string;
@@ -67,4 +76,4 @@ export declare function pushBackportBranch({ options, backportBranch, }: {
67
76
  stdout: string;
68
77
  stderr: string;
69
78
  }>;
70
- export declare function getSourceRepoPath(options: ValidConfigOptions): Promise<string>;
79
+ export declare function getLocalRepoPath(options: ValidConfigOptions): Promise<string | undefined>;
@@ -24,7 +24,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  const promises_1 = require("fs/promises");
26
26
  const make_dir_1 = __importDefault(require("make-dir"));
27
- const nockHelpers_1 = require("../test/nockHelpers");
28
27
  const sandbox_1 = require("../test/sandbox");
29
28
  const childProcess = __importStar(require("./child-process-promisified"));
30
29
  const git_1 = require("./git");
@@ -186,44 +185,36 @@ describe('git.integration', () => {
186
185
  await expect(() => (0, promises_1.access)(`${backportRepo}/my-file.txt`)).not.toThrowError();
187
186
  });
188
187
  });
189
- describe('getSourceRepoPath', () => {
190
- let sourceRepo;
188
+ describe('getLocalRepoPath', () => {
189
+ let sandboxPath;
191
190
  beforeEach(async () => {
192
- const sandboxPath = (0, sandbox_1.getSandboxPath)({
191
+ sandboxPath = (0, sandbox_1.getSandboxPath)({
193
192
  filename: __filename,
194
- specname: 'getSourceRepoPath',
193
+ specname: 'getLocalRepoPath',
195
194
  });
196
- sourceRepo = `${sandboxPath}/source-repo`;
197
195
  await (0, sandbox_1.resetSandbox)(sandboxPath);
198
- await (0, make_dir_1.default)(sourceRepo);
199
- const execOpts = { cwd: sourceRepo };
196
+ const execOpts = { cwd: sandboxPath };
200
197
  await childProcess.exec(`git init`, execOpts);
201
- await childProcess.exec(`git remote add origin git@github.com:elastic/kibana.git`, execOpts);
202
- mockRepoOwnerAndName({
203
- childRepoOwner: 'sqren',
204
- parentRepoOwner: 'elastic',
205
- repoName: 'kibana',
206
- });
198
+ await childProcess.exec(`git remote add sqren git@github.com:sqren/kibana.git`, execOpts);
199
+ await childProcess.exec(`git remote add elastic git@github.com:elastic/kibana.git`, execOpts);
207
200
  });
208
201
  it('returns local source repo, when one remote matches', async () => {
209
202
  const options = {
210
- accessToken: 'verysecret',
211
203
  repoName: 'kibana',
212
204
  repoOwner: 'elastic',
213
- cwd: sourceRepo,
205
+ cwd: sandboxPath,
214
206
  githubApiBaseUrlV4: 'http://localhost/graphql', // required to mock the response
215
207
  };
216
- expect(await (0, git_1.getSourceRepoPath)(options)).toBe(sourceRepo);
208
+ expect(await (0, git_1.getLocalRepoPath)(options)).toBe(sandboxPath);
217
209
  });
218
- it("returns remote source repo when remotes don't match", async () => {
210
+ it('returns undefined when no remotes match', async () => {
219
211
  const options = {
220
- accessToken: 'verysecret',
221
212
  repoName: 'kibana',
222
213
  repoOwner: 'not-a-match',
223
- cwd: sourceRepo,
214
+ cwd: sandboxPath,
224
215
  githubApiBaseUrlV4: 'http://localhost/graphql', // required to mock the response
225
216
  };
226
- expect(await (0, git_1.getSourceRepoPath)(options)).toBe('https://x-access-token:verysecret@github.com/not-a-match/kibana.git');
217
+ expect(await (0, git_1.getLocalRepoPath)(options)).toBe(undefined);
227
218
  });
228
219
  });
229
220
  describe('when cloning "backport-org/different-merge-strategies"', () => {
@@ -293,28 +284,3 @@ async function getCurrentMessage(execOpts) {
293
284
  const { stdout } = await childProcess.exec('git --no-pager log -1 --pretty=%B', execOpts);
294
285
  return stdout.trim();
295
286
  }
296
- function mockRepoOwnerAndName({ repoName, parentRepoOwner, childRepoOwner, }) {
297
- return (0, nockHelpers_1.mockGqlRequest)({
298
- name: 'RepoOwnerAndName',
299
- statusCode: 200,
300
- body: {
301
- data: {
302
- // @ts-expect-error
303
- repository: {
304
- isFork: !!parentRepoOwner,
305
- name: repoName,
306
- owner: {
307
- login: childRepoOwner,
308
- },
309
- parent: parentRepoOwner
310
- ? {
311
- owner: {
312
- login: parentRepoOwner,
313
- },
314
- }
315
- : null,
316
- },
317
- },
318
- },
319
- });
320
- }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSourceRepoPath = exports.pushBackportBranch = exports.getRepoForkOwner = exports.deleteBackportBranch = exports.createBackportBranch = exports.setCommitAuthor = exports.getUnstagedFiles = exports.getConflictingFiles = exports.commitChanges = exports.cherrypick = exports.getCommitsInMergeCommit = exports.getIsMergeCommit = exports.fetchBranch = exports.addRemote = exports.deleteRemote = exports.getIsCommitInBranch = exports.getGitProjectRoot = exports.getRepoInfoFromGitRemotes = exports.isLocalConfigFileModified = exports.isLocalConfigFileUntracked = exports.getLocalConfigFileCommitDate = exports.cloneRepo = exports.getRemoteUrl = void 0;
3
+ exports.getLocalRepoPath = exports.pushBackportBranch = exports.getRepoForkOwner = exports.deleteBackportBranch = exports.createBackportBranch = exports.setGitConfig = exports.getGitConfig = exports.setCommitAuthor = exports.getUnstagedFiles = exports.getConflictingFiles = exports.commitChanges = exports.cherrypick = exports.getCommitsInMergeCommit = exports.getIsMergeCommit = exports.fetchBranch = exports.addRemote = exports.deleteRemote = exports.getIsCommitInBranch = exports.getGitProjectRootPath = exports.getRepoInfoFromGitRemotes = exports.isLocalConfigFileModified = exports.isLocalConfigFileUntracked = exports.getLocalConfigFileCommitDate = exports.cloneRepo = exports.getRemoteUrl = void 0;
4
4
  const path_1 = require("path");
5
5
  const lodash_1 = require("lodash");
6
6
  const ora_1 = require("../ui/ora");
@@ -9,7 +9,6 @@ const HandledError_1 = require("./HandledError");
9
9
  const child_process_promisified_1 = require("./child-process-promisified");
10
10
  const env_1 = require("./env");
11
11
  const commitFormatters_1 = require("./github/commitFormatters");
12
- const getRepoOwnerAndNameFromGitRemotes_1 = require("./github/v4/getRepoOwnerAndNameFromGitRemotes");
13
12
  const logger_1 = require("./logger");
14
13
  function getRemoteUrl({ repoName, accessToken, gitHostname = 'github.com' }, repoOwner) {
15
14
  return `https://x-access-token:${accessToken}@${gitHostname}/${repoOwner}/${repoName}.git`;
@@ -85,7 +84,7 @@ async function getRepoInfoFromGitRemotes({ cwd }) {
85
84
  const remotes = stdout
86
85
  .split('\n')
87
86
  .map((line) => {
88
- const match = line.match(/.+github.com:(.+?)(.git)? \((fetch|push)\)/);
87
+ const match = line.match(/github.com[/|:](.+?)(.git)? \((fetch|push)\)/);
89
88
  return match?.[1];
90
89
  })
91
90
  .filter(filterEmpty_1.filterNil);
@@ -99,7 +98,7 @@ async function getRepoInfoFromGitRemotes({ cwd }) {
99
98
  }
100
99
  }
101
100
  exports.getRepoInfoFromGitRemotes = getRepoInfoFromGitRemotes;
102
- async function getGitProjectRoot(dir) {
101
+ async function getGitProjectRootPath(dir) {
103
102
  try {
104
103
  const { stdout } = await (0, child_process_promisified_1.exec)('git rev-parse --show-toplevel', {
105
104
  cwd: dir,
@@ -111,7 +110,7 @@ async function getGitProjectRoot(dir) {
111
110
  return;
112
111
  }
113
112
  }
114
- exports.getGitProjectRoot = getGitProjectRoot;
113
+ exports.getGitProjectRootPath = getGitProjectRootPath;
115
114
  async function getIsCommitInBranch(options, commitSha) {
116
115
  try {
117
116
  await (0, child_process_promisified_1.exec)(`git merge-base --is-ancestor ${commitSha} HEAD`, {
@@ -320,6 +319,26 @@ async function setCommitAuthor(options, author) {
320
319
  }
321
320
  }
322
321
  exports.setCommitAuthor = setCommitAuthor;
322
+ async function getGitConfig({ dir, key, }) {
323
+ try {
324
+ const res = await (0, child_process_promisified_1.exec)(`git config ${key}`, { cwd: dir });
325
+ return res.stdout;
326
+ }
327
+ catch (e) {
328
+ return;
329
+ }
330
+ }
331
+ exports.getGitConfig = getGitConfig;
332
+ async function setGitConfig({ dir, key, value, }) {
333
+ try {
334
+ await (0, child_process_promisified_1.exec)(`git config ${key} ${value}`, { cwd: dir });
335
+ }
336
+ catch (e) {
337
+ logger_1.logger.error(`Could not set git config: ${key}=${value}`, e);
338
+ return;
339
+ }
340
+ }
341
+ exports.setGitConfig = setGitConfig;
323
342
  // How the commit flows:
324
343
  // ${sourceBranch} -> ${backportBranch} -> ${targetBranch}
325
344
  // master -> backport/7.x/pr-1234 -> 7.x
@@ -371,14 +390,11 @@ async function pushBackportBranch({ options, backportBranch, }) {
371
390
  }
372
391
  }
373
392
  exports.pushBackportBranch = pushBackportBranch;
374
- async function getSourceRepoPath(options) {
375
- const gitRemote = await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)(options);
376
- // where to fetch the repo from (either remotely from Github or from a local path)
377
- const remoteUrl = getRemoteUrl(options, options.repoOwner);
378
- const sourcePath = options.repoName === gitRemote.repoName &&
379
- options.repoOwner === gitRemote.repoOwner
380
- ? (await getGitProjectRoot(options.cwd)) ?? remoteUrl
381
- : remoteUrl;
382
- return sourcePath;
393
+ // retrieve path to local repo (cwd) if it matches `repoName` / `repoOwner`
394
+ async function getLocalRepoPath(options) {
395
+ const remotes = await getRepoInfoFromGitRemotes({ cwd: options.cwd });
396
+ const hasMatchingGitRemote = remotes.some((remote) => remote.repoName === options.repoName &&
397
+ remote.repoOwner === options.repoOwner);
398
+ return hasMatchingGitRemote ? getGitProjectRootPath(options.cwd) : undefined;
383
399
  }
384
- exports.getSourceRepoPath = getSourceRepoPath;
400
+ exports.getLocalRepoPath = getLocalRepoPath;
@@ -140,7 +140,7 @@ describe('isLocalConfigFileModified', () => {
140
140
  });
141
141
  });
142
142
  describe('getRepoInfoFromGitRemotes', () => {
143
- it('returns repoName and repoOwner for every remote', async () => {
143
+ it('returns repoName and repoOwner ssh remotes', async () => {
144
144
  const res = {
145
145
  stdout: 'john.doe\tgit@github.com:john.doe/kibana (fetch)\n' +
146
146
  'john.doe\tgit@github.com:john.doe/kibana (push)\n' +
@@ -160,6 +160,16 @@ describe('getRepoInfoFromGitRemotes', () => {
160
160
  { repoName: 'kibana', repoOwner: 'sqren' },
161
161
  ]);
162
162
  });
163
+ it('returns repoName and repoOwner https remotes', async () => {
164
+ jest.spyOn(childProcess, 'exec').mockResolvedValue({
165
+ stdout: 'origin\thttps://github.com/shay/elasticsearch.git (fetch)\n' +
166
+ 'origin\thttps://github.com/shay/elasticsearch.git (push)\n',
167
+ stderr: '',
168
+ });
169
+ expect(await (0, git_1.getRepoInfoFromGitRemotes)({ cwd: 'foo/bar' })).toEqual([
170
+ { repoName: 'elasticsearch', repoOwner: 'shay' },
171
+ ]);
172
+ });
163
173
  it('returns undefined when no remotes exist', async () => {
164
174
  const res = { stdout: '', stderr: '' };
165
175
  jest.spyOn(childProcess, 'exec').mockResolvedValue(res);
@@ -421,6 +431,7 @@ describe('commitChanges', () => {
421
431
  repoName: 'kibana',
422
432
  };
423
433
  const commit = {
434
+ author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
424
435
  sourceCommit: {
425
436
  message: 'The original commit message',
426
437
  committedDate: '2020',
@@ -7,6 +7,10 @@ describe('getPullRequestBody', () => {
7
7
  options: {},
8
8
  commits: [
9
9
  {
10
+ author: {
11
+ email: 'soren.louv@elastic.co',
12
+ name: 'Søren Louv-Jansen',
13
+ },
10
14
  sourcePullRequest: {
11
15
  number: 55,
12
16
  url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
@@ -42,6 +46,10 @@ describe('getPullRequestBody', () => {
42
46
  options: {},
43
47
  commits: [
44
48
  {
49
+ author: {
50
+ email: 'soren.louv@elastic.co',
51
+ name: 'Søren Louv-Jansen',
52
+ },
45
53
  sourceCommit: {
46
54
  committedDate: '',
47
55
  sha: 'abcdefghijklmw',
@@ -69,6 +77,10 @@ describe('getPullRequestBody', () => {
69
77
  options: {},
70
78
  commits: [
71
79
  {
80
+ author: {
81
+ email: 'soren.louv@elastic.co',
82
+ name: 'Søren Louv-Jansen',
83
+ },
72
84
  sourcePullRequest: {
73
85
  number: 55,
74
86
  url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
@@ -86,6 +98,10 @@ describe('getPullRequestBody', () => {
86
98
  expectedTargetPullRequests: [],
87
99
  },
88
100
  {
101
+ author: {
102
+ email: 'soren.louv@elastic.co',
103
+ name: 'Søren Louv-Jansen',
104
+ },
89
105
  sourceCommit: {
90
106
  committedDate: '',
91
107
  sha: 'qwertyuiop',
@@ -119,6 +135,10 @@ describe('getPullRequestBody', () => {
119
135
  message: 'Merge strategy: Second commit',
120
136
  sha: 'e8df5eaa4db7b94474b48e2320b02d33a830d9fb',
121
137
  },
138
+ author: {
139
+ email: 'soren.louv@elastic.co',
140
+ name: 'Søren Louv-Jansen',
141
+ },
122
142
  sourcePullRequest: {
123
143
  number: 1,
124
144
  url: 'https://github.com/backport-org/different-merge-strategies/pull/1',
@@ -136,6 +156,10 @@ describe('getPullRequestBody', () => {
136
156
  message: 'Merge strategy: First commit',
137
157
  sha: '5411b1c1144093e422220008f23f2c2b909ed113',
138
158
  },
159
+ author: {
160
+ email: 'soren.louv@elastic.co',
161
+ name: 'Søren Louv-Jansen',
162
+ },
139
163
  sourcePullRequest: {
140
164
  number: 1,
141
165
  url: 'https://github.com/backport-org/different-merge-strategies/pull/1',
@@ -169,6 +193,10 @@ describe('getPullRequestBody', () => {
169
193
  },
170
194
  commits: [
171
195
  {
196
+ author: {
197
+ email: 'soren.louv@elastic.co',
198
+ name: 'Søren Louv-Jansen',
199
+ },
172
200
  sourcePullRequest: {
173
201
  number: 55,
174
202
  url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
@@ -186,6 +214,10 @@ describe('getPullRequestBody', () => {
186
214
  expectedTargetPullRequests: [],
187
215
  },
188
216
  {
217
+ author: {
218
+ email: 'soren.louv@elastic.co',
219
+ name: 'Søren Louv-Jansen',
220
+ },
189
221
  sourceCommit: {
190
222
  committedDate: '',
191
223
  sha: 'qwertyuiop',
@@ -209,6 +241,10 @@ describe('getPullRequestBody', () => {
209
241
  },
210
242
  commits: [
211
243
  {
244
+ author: {
245
+ email: 'soren.louv@elastic.co',
246
+ name: 'Søren Louv-Jansen',
247
+ },
212
248
  sourcePullRequest: {
213
249
  number: 55,
214
250
  url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
@@ -226,6 +262,10 @@ describe('getPullRequestBody', () => {
226
262
  expectedTargetPullRequests: [],
227
263
  },
228
264
  {
265
+ author: {
266
+ email: 'soren.louv@elastic.co',
267
+ name: 'Søren Louv-Jansen',
268
+ },
229
269
  sourceCommit: {
230
270
  committedDate: '',
231
271
  sha: 'qwertyuiop',
@@ -258,6 +298,10 @@ describe('getTitle', () => {
258
298
  options: {},
259
299
  commits: [
260
300
  {
301
+ author: {
302
+ email: 'soren.louv@elastic.co',
303
+ name: 'Søren Louv-Jansen',
304
+ },
261
305
  sourceBranch: 'main',
262
306
  sourcePullRequest: {
263
307
  number: 55,
@@ -275,6 +319,10 @@ describe('getTitle', () => {
275
319
  expectedTargetPullRequests: [],
276
320
  },
277
321
  {
322
+ author: {
323
+ email: 'soren.louv@elastic.co',
324
+ name: 'Søren Louv-Jansen',
325
+ },
278
326
  sourcePullRequest: {
279
327
  number: 56,
280
328
  url: 'https://github.com/backport-org/different-merge-strategies/pull/56',
@@ -302,6 +350,10 @@ describe('getTitle', () => {
302
350
  },
303
351
  commits: [
304
352
  {
353
+ author: {
354
+ email: 'soren.louv@elastic.co',
355
+ name: 'Søren Louv-Jansen',
356
+ },
305
357
  sourcePullRequest: {
306
358
  number: 55,
307
359
  url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
@@ -266,9 +266,13 @@ describe('getCommentBody', () => {
266
266
  error: new HandledError_1.HandledError({
267
267
  code: 'merge-conflict-exception',
268
268
  commitsWithoutBackports: [
269
- //@ts-expect-error
270
269
  {
270
+ formatted: 'some-formatted-text',
271
271
  commit: {
272
+ author: {
273
+ email: 'soren.louv@elastic.co',
274
+ name: 'Søren Louv-Jansen',
275
+ },
272
276
  sourceBranch: 'master',
273
277
  sourcePullRequest: {
274
278
  number: 5,
@@ -287,8 +291,13 @@ describe('getCommentBody', () => {
287
291
  },
288
292
  },
289
293
  {
290
- //@ts-expect-error
294
+ formatted: 'some-formatted-text',
291
295
  commit: {
296
+ author: {
297
+ email: 'soren.louv@elastic.co',
298
+ name: 'Søren Louv-Jansen',
299
+ },
300
+ sourceBranch: 'master',
292
301
  sourcePullRequest: {
293
302
  number: 44,
294
303
  url: 'url-to-pr-44',
@@ -302,6 +311,7 @@ describe('getCommentBody', () => {
302
311
  sha: '',
303
312
  message: 'Australia commit',
304
313
  },
314
+ expectedTargetPullRequests: [],
305
315
  },
306
316
  },
307
317
  ],
@@ -61,6 +61,7 @@ describe('allFetchers', () => {
61
61
  });
62
62
  it('returns correct response for commitByAuthor', async () => {
63
63
  const expectedCommit = {
64
+ author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
64
65
  sourceCommit: {
65
66
  committedDate: '2021-12-20T14:20:16Z',
66
67
  message: '[APM] Add note about synthtrace to APM docs (#121633)',
@@ -67,6 +67,7 @@ describe('fetchCommitByPullNumber', () => {
67
67
  sourceBranch: 'main',
68
68
  };
69
69
  const expectedCommit = {
70
+ author: { email: 'sorenlouv@gmail.com', name: 'Søren Louv-Jansen' },
70
71
  sourceCommit: {
71
72
  committedDate: '2020-08-15T12:40:19Z',
72
73
  message: 'Add 🍏 emoji (#5)',
@@ -60,6 +60,7 @@ describe('fetchCommitBySha', () => {
60
60
  });
61
61
  it('should return single commit with pull request', async () => {
62
62
  const expectedCommit = {
63
+ author: { email: 'sorenlouv@gmail.com', name: 'Søren Louv-Jansen' },
63
64
  sourceCommit: {
64
65
  committedDate: '2020-07-07T20:40:28Z',
65
66
  message: '[APM] Add API tests (#70740)',
@@ -46,6 +46,7 @@ describe('fetchCommitsByAuthor', () => {
46
46
  it('should return a list of commits with pullNumber and existing backports', () => {
47
47
  const expectedCommits = [
48
48
  {
49
+ author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
49
50
  sourceCommit: {
50
51
  committedDate: '2021-12-24T00:00:00Z',
51
52
  sha: '2e63475c483f7844b0f2833bc57fdee32095bacb',
@@ -55,6 +56,7 @@ describe('fetchCommitsByAuthor', () => {
55
56
  sourceBranch: 'source-branch-from-options',
56
57
  },
57
58
  {
59
+ author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
58
60
  sourceCommit: {
59
61
  committedDate: '2021-12-23T00:00:00Z',
60
62
  sha: 'f3b618b9421fdecdb36862f907afbdd6344b361d',
@@ -72,6 +74,7 @@ describe('fetchCommitsByAuthor', () => {
72
74
  sourceBranch: 'master',
73
75
  },
74
76
  {
77
+ author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
75
78
  sourceCommit: {
76
79
  committedDate: '2021-12-22T00:00:00Z',
77
80
  sha: '79cf18453ec32a4677009dcbab1c9c8c73fc14fe',
@@ -100,6 +103,7 @@ describe('fetchCommitsByAuthor', () => {
100
103
  sourceBranch: 'master',
101
104
  },
102
105
  {
106
+ author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
103
107
  sourceCommit: {
104
108
  committedDate: '2021-12-21T00:00:00Z',
105
109
  sha: '3827bbbaf39914eda4f02f6940189844375fd097',
@@ -109,6 +113,7 @@ describe('fetchCommitsByAuthor', () => {
109
113
  sourceBranch: 'source-branch-from-options',
110
114
  },
111
115
  {
116
+ author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
112
117
  sourceCommit: {
113
118
  committedDate: '2021-12-20T00:00:00Z',
114
119
  sha: '5ea0da550ac191029459289d67f99ad7d310812b',
@@ -34,6 +34,7 @@ describe('fetchPullRequestBySearchQuery', () => {
34
34
  };
35
35
  const expectedCommits = [
36
36
  {
37
+ author: { email: 'sorenlouv@gmail.com', name: 'Søren Louv-Jansen' },
37
38
  sourceCommit: {
38
39
  committedDate: '2020-08-16T21:44:28Z',
39
40
  message: 'Add sheep emoji (#9)',
@@ -58,6 +59,7 @@ describe('fetchPullRequestBySearchQuery', () => {
58
59
  ],
59
60
  },
60
61
  {
62
+ author: { email: 'sorenlouv@gmail.com', name: 'Søren Louv-Jansen' },
61
63
  sourceCommit: {
62
64
  committedDate: '2020-08-15T12:40:19Z',
63
65
  message: 'Add 🍏 emoji (#5)',
@@ -32,6 +32,8 @@ export declare function getOptionsFromGithub(options: {
32
32
  gitHostname?: string | undefined;
33
33
  githubApiBaseUrlV3?: string | undefined;
34
34
  githubApiBaseUrlV4?: string | undefined;
35
+ gitUserEmail?: string | undefined;
36
+ gitUserName?: string | undefined;
35
37
  logFilePath?: string | undefined;
36
38
  maxNumber?: number | undefined;
37
39
  multiple?: boolean | undefined;
@@ -9,6 +9,7 @@ const maybe_1 = require("../../../utils/maybe");
9
9
  const git_1 = require("../../git");
10
10
  const logger_1 = require("../../logger");
11
11
  const apiRequestV4_1 = require("./apiRequestV4");
12
+ // This method should be used to get the origin owner (instead of a fork owner)
12
13
  async function getRepoOwnerAndNameFromGitRemotes({ accessToken, githubApiBaseUrlV4, cwd, }) {
13
14
  const remotes = await (0, git_1.getRepoInfoFromGitRemotes)({ cwd });
14
15
  const firstRemote = (0, maybe_1.maybe)(remotes[0]);