backport 7.2.0-beta.2 → 7.2.0-beta.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 (104) hide show
  1. package/dist/entrypoint.cli.private.test.d.ts +1 -0
  2. package/dist/entrypoint.cli.private.test.js +46 -0
  3. package/dist/options/cliArgs.test.d.ts +1 -0
  4. package/dist/options/cliArgs.test.js +182 -0
  5. package/dist/options/config/config.test.d.ts +1 -0
  6. package/dist/options/config/config.test.js +32 -0
  7. package/dist/options/config/globalConfig.test.d.ts +1 -0
  8. package/dist/options/config/globalConfig.test.js +61 -0
  9. package/dist/options/config/projectConfig.test.d.ts +1 -0
  10. package/dist/options/config/projectConfig.test.js +109 -0
  11. package/dist/options/options.test.d.ts +1 -0
  12. package/dist/options/options.test.js +384 -0
  13. package/dist/runSequentially.test.d.ts +1 -0
  14. package/dist/runSequentially.test.js +243 -0
  15. package/dist/scripts/postinstall.test.d.ts +1 -0
  16. package/dist/scripts/postinstall.test.js +53 -0
  17. package/dist/services/env.test.d.ts +1 -0
  18. package/dist/services/env.test.js +21 -0
  19. package/dist/services/git.d.ts +1 -3
  20. package/dist/services/git.integration.test.d.ts +1 -0
  21. package/dist/services/git.integration.test.js +320 -0
  22. package/dist/services/git.js +5 -3
  23. package/dist/services/git.test.d.ts +1 -0
  24. package/dist/services/git.test.js +532 -0
  25. package/dist/services/github/commitFormatters.test.d.ts +1 -0
  26. package/dist/services/github/commitFormatters.test.js +11 -0
  27. package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +1 -0
  28. package/dist/services/github/v3/addAssigneesToPullRequest.test.js +27 -0
  29. package/dist/services/github/v3/createPullRequest.test.d.ts +1 -0
  30. package/dist/services/github/v3/createPullRequest.test.js +325 -0
  31. package/dist/services/github/v3/createStatusComment.test.d.ts +1 -0
  32. package/dist/services/github/v3/createStatusComment.test.js +386 -0
  33. package/dist/services/github/v4/apiRequestV4.test.d.ts +1 -0
  34. package/dist/services/github/v4/apiRequestV4.test.js +109 -0
  35. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
  36. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
  37. package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +1 -0
  38. package/dist/services/github/v4/fetchAuthorId.private.test.js +28 -0
  39. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
  40. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +93 -0
  41. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
  42. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +134 -0
  43. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
  44. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +116 -0
  45. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
  46. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +195 -0
  47. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
  48. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +152 -0
  49. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
  50. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +102 -0
  51. package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +1 -0
  52. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +47 -0
  53. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
  54. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +52 -0
  55. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
  56. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +117 -0
  57. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +1 -0
  58. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +71 -0
  59. package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +2 -0
  60. package/dist/services/github/v4/mocks/commitsByAuthorMock.js +156 -0
  61. package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +1 -0
  62. package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +87 -0
  63. package/dist/services/prompt.test.d.ts +1 -0
  64. package/dist/services/prompt.test.js +134 -0
  65. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
  66. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +467 -0
  67. package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +1 -0
  68. package/dist/services/sourceCommit/parseSourceCommit.test.js +225 -0
  69. package/dist/test/ExecError.d.ts +16 -0
  70. package/dist/test/ExecError.js +15 -0
  71. package/dist/test/e2e/cli.e2e.private.test.d.ts +1 -0
  72. package/dist/test/e2e/cli.e2e.private.test.js +433 -0
  73. package/dist/test/e2e/module.e2e.private.test.d.ts +1 -0
  74. package/dist/test/e2e/module.e2e.private.test.js +363 -0
  75. package/dist/test/handleUnbackportedPullRequests.private.test.d.ts +1 -0
  76. package/dist/test/handleUnbackportedPullRequests.private.test.js +55 -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 +36 -0
  83. package/dist/test/private/getDevAccessToken.d.ts +2 -0
  84. package/dist/test/private/getDevAccessToken.js +12 -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 +63 -0
  89. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
  90. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +459 -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.js +7 -3
  96. package/dist/ui/maybeSetupRepo.test.d.ts +1 -0
  97. package/dist/ui/maybeSetupRepo.test.js +238 -0
  98. package/dist/ui/ora.d.ts +1 -1
  99. package/dist/ui/ora.js +2 -2
  100. package/dist/utils/excludeUndefined.test.d.ts +1 -0
  101. package/dist/utils/excludeUndefined.test.js +24 -0
  102. package/dist/utils/packageVersion.d.ts +1 -1
  103. package/dist/utils/packageVersion.js +1 -1
  104. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
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 os_1 = __importDefault(require("os"));
7
+ const env_1 = require("../services/env");
8
+ describe('env', () => {
9
+ beforeEach(() => {
10
+ jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
11
+ });
12
+ it('getGlobalConfigPath', () => {
13
+ expect((0, env_1.getGlobalConfigPath)()).toBe('/myHomeDir/.backport/config.json');
14
+ });
15
+ it('getRepoPath', () => {
16
+ expect((0, env_1.getRepoPath)({
17
+ repoOwner: 'elastic',
18
+ repoName: 'kibana',
19
+ })).toBe('/myHomeDir/.backport/repositories/elastic/kibana');
20
+ });
21
+ });
@@ -21,9 +21,7 @@ export declare function getRepoInfoFromGitRemotes({ cwd }: {
21
21
  repoOwner: string;
22
22
  repoName: string;
23
23
  }[]>;
24
- export declare function getGitProjectRoot({ cwd }: {
25
- cwd: string;
26
- }): Promise<string | undefined>;
24
+ export declare function getGitProjectRoot(dir: string): Promise<string | undefined>;
27
25
  export declare function getIsCommitInBranch(options: ValidConfigOptions, commitSha: string): Promise<boolean>;
28
26
  export declare function deleteRemote(options: ValidConfigOptions, remoteName: string): Promise<void>;
29
27
  export declare function addRemote(options: ValidConfigOptions, remoteName: string): Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,320 @@
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 make_dir_1 = __importDefault(require("make-dir"));
27
+ const nockHelpers_1 = require("../test/nockHelpers");
28
+ const sandbox_1 = require("../test/sandbox");
29
+ const childProcess = __importStar(require("./child-process-promisified"));
30
+ const git_1 = require("./git");
31
+ const commitFormatters_1 = require("./github/commitFormatters");
32
+ jest.unmock('del');
33
+ jest.unmock('make-dir');
34
+ describe('git.integration', () => {
35
+ describe('getIsCommitInBranch', () => {
36
+ let firstSha;
37
+ let secondSha;
38
+ const sandboxPath = (0, sandbox_1.getSandboxPath)({
39
+ filename: __filename,
40
+ specname: 'getIsCommitInBranch',
41
+ });
42
+ beforeEach(async () => {
43
+ await (0, sandbox_1.resetSandbox)(sandboxPath);
44
+ const execOpts = { cwd: sandboxPath };
45
+ // create and commit first file
46
+ await childProcess.exec('git init', execOpts);
47
+ firstSha = await createAndCommitFile({
48
+ filename: 'foo.md',
49
+ content: 'My first file',
50
+ execOpts,
51
+ });
52
+ // create 7.x branch (but stay on `main` branch)
53
+ await childProcess.exec('git branch 7.x', execOpts);
54
+ // create and commit second file
55
+ secondSha = await createAndCommitFile({
56
+ filename: 'bar.md',
57
+ content: 'My second file',
58
+ execOpts,
59
+ });
60
+ // checkout 7.x
61
+ await childProcess.exec('git checkout 7.x', execOpts);
62
+ });
63
+ it('should contain the first commit', async () => {
64
+ const isFirstCommitInBranch = await (0, git_1.getIsCommitInBranch)({ dir: sandboxPath }, firstSha);
65
+ expect(isFirstCommitInBranch).toEqual(true);
66
+ });
67
+ it('should not contain the second commit', async () => {
68
+ const isSecondCommitInBranch = await (0, git_1.getIsCommitInBranch)({ dir: sandboxPath }, secondSha);
69
+ expect(isSecondCommitInBranch).toEqual(false);
70
+ });
71
+ it('should not contain a random commit', async () => {
72
+ const isSecondCommitInBranch = await (0, git_1.getIsCommitInBranch)({ dir: sandboxPath }, 'abcdefg');
73
+ expect(isSecondCommitInBranch).toEqual(false);
74
+ });
75
+ });
76
+ describe('cherrypick', () => {
77
+ let firstSha;
78
+ let secondSha;
79
+ let fourthSha;
80
+ let execOpts;
81
+ const sandboxPath = (0, sandbox_1.getSandboxPath)({
82
+ filename: __filename,
83
+ specname: 'cherrypick',
84
+ });
85
+ beforeEach(async () => {
86
+ await (0, sandbox_1.resetSandbox)(sandboxPath);
87
+ execOpts = { cwd: sandboxPath };
88
+ // create and commit first file
89
+ await childProcess.exec('git init', execOpts);
90
+ firstSha = await createAndCommitFile({
91
+ filename: 'foo.md',
92
+ content: 'Creating first file',
93
+ execOpts,
94
+ });
95
+ // create 7.x branch (but stay on `main` branch)
96
+ await childProcess.exec('git branch 7.x', execOpts);
97
+ // create and commit second file
98
+ secondSha = await createAndCommitFile({
99
+ filename: 'bar.md',
100
+ content: 'Creating second file\nHello',
101
+ execOpts,
102
+ });
103
+ // edit first file
104
+ await createAndCommitFile({
105
+ filename: 'foo.md',
106
+ content: 'Changing first file',
107
+ execOpts,
108
+ });
109
+ // edit first file
110
+ fourthSha = await createAndCommitFile({
111
+ filename: 'foo.md',
112
+ content: 'Some more changes to the first file',
113
+ execOpts,
114
+ });
115
+ // checkout 7.x
116
+ await childProcess.exec('git checkout 7.x', execOpts);
117
+ });
118
+ it('should not cherrypick commit that already exists', async () => {
119
+ const shortSha = (0, commitFormatters_1.getShortSha)(firstSha);
120
+ return expect(() => (0, git_1.cherrypick)({ dir: sandboxPath }, firstSha)).rejects.toThrowError(`Cherrypick failed because the selected commit (${shortSha}) is empty. Did you already backport this commit?`);
121
+ });
122
+ it('should cherrypick commit cleanly', async () => {
123
+ const res = await (0, git_1.cherrypick)({
124
+ cherrypickRef: false,
125
+ dir: sandboxPath,
126
+ }, secondSha);
127
+ expect(res).toEqual({
128
+ conflictingFiles: [],
129
+ needsResolving: false,
130
+ unstagedFiles: [],
131
+ });
132
+ const message = await getCurrentMessage(execOpts);
133
+ expect(message).toEqual(`Update bar.md`);
134
+ });
135
+ it('should cherrypick commit cleanly and append "(cherry picked from commit...)"', async () => {
136
+ const res = await (0, git_1.cherrypick)({
137
+ cherrypickRef: true,
138
+ dir: sandboxPath,
139
+ }, secondSha);
140
+ expect(res).toEqual({
141
+ conflictingFiles: [],
142
+ needsResolving: false,
143
+ unstagedFiles: [],
144
+ });
145
+ const message = await getCurrentMessage(execOpts);
146
+ expect(message).toEqual(`Update bar.md\n\n(cherry picked from commit ${secondSha})`);
147
+ });
148
+ it('should cherrypick commit with conflicts', async () => {
149
+ const res = await (0, git_1.cherrypick)({ dir: sandboxPath }, fourthSha);
150
+ expect(res).toEqual({
151
+ needsResolving: true,
152
+ conflictingFiles: [
153
+ {
154
+ absolute: `${sandboxPath}/foo.md`,
155
+ relative: 'foo.md',
156
+ },
157
+ ],
158
+ unstagedFiles: [`${sandboxPath}/foo.md`],
159
+ });
160
+ });
161
+ });
162
+ describe('cloneRepo', () => {
163
+ const sandboxPath = (0, sandbox_1.getSandboxPath)({
164
+ filename: __filename,
165
+ specname: 'cloneRepo',
166
+ });
167
+ const sourceRepo = `${sandboxPath}/source-repo`;
168
+ const backportRepo = `${sandboxPath}/backport-repo`;
169
+ beforeEach(async () => {
170
+ await (0, sandbox_1.resetSandbox)(sandboxPath);
171
+ await (0, make_dir_1.default)(sourceRepo);
172
+ const execOpts = { cwd: sourceRepo };
173
+ await childProcess.exec(`git init`, execOpts);
174
+ await childProcess.exec(`git remote add origin git@github.com:elastic/kibana.git`, execOpts);
175
+ await createAndCommitFile({
176
+ filename: 'my-file.txt',
177
+ content: 'Hello!',
178
+ execOpts,
179
+ });
180
+ });
181
+ it('clones the repo', async () => {
182
+ // file should not exist before clone
183
+ await expect(() => (0, promises_1.access)(`${backportRepo}/my-file.txt`)).rejects.toThrowError();
184
+ await (0, git_1.cloneRepo)({ sourcePath: sourceRepo, targetPath: backportRepo }, () => null);
185
+ //file should exist after clone
186
+ await expect(() => (0, promises_1.access)(`${backportRepo}/my-file.txt`)).not.toThrowError();
187
+ });
188
+ });
189
+ describe('getSourceRepoPath', () => {
190
+ let sourceRepo;
191
+ beforeEach(async () => {
192
+ const sandboxPath = (0, sandbox_1.getSandboxPath)({
193
+ filename: __filename,
194
+ specname: 'getSourceRepoPath',
195
+ });
196
+ sourceRepo = `${sandboxPath}/source-repo`;
197
+ await (0, sandbox_1.resetSandbox)(sandboxPath);
198
+ await (0, make_dir_1.default)(sourceRepo);
199
+ const execOpts = { cwd: sourceRepo };
200
+ 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
+ });
207
+ });
208
+ it('returns local source repo, when one remote matches', async () => {
209
+ const options = {
210
+ accessToken: 'verysecret',
211
+ repoName: 'kibana',
212
+ repoOwner: 'elastic',
213
+ cwd: sourceRepo,
214
+ githubApiBaseUrlV4: 'http://localhost/graphql', // required to mock the response
215
+ };
216
+ expect(await (0, git_1.getSourceRepoPath)(options)).toBe(sourceRepo);
217
+ });
218
+ it("returns remote source repo when remotes don't match", async () => {
219
+ const options = {
220
+ accessToken: 'verysecret',
221
+ repoName: 'kibana',
222
+ repoOwner: 'not-a-match',
223
+ cwd: sourceRepo,
224
+ githubApiBaseUrlV4: 'http://localhost/graphql', // required to mock the response
225
+ };
226
+ expect(await (0, git_1.getSourceRepoPath)(options)).toBe('https://x-access-token:verysecret@github.com/not-a-match/kibana.git');
227
+ });
228
+ });
229
+ describe('when cloning "backport-org/different-merge-strategies"', () => {
230
+ const MERGE_COMMIT_HASH_1 = 'bdc5a17f81e5f32129e27b05c742e055c650bc54';
231
+ const MERGE_COMMIT_HASH_2 = '0db7f1ac1233461563d8708511d1c14adbab46da';
232
+ const SQUASH_COMMIT_HASH = '74a76fa64b34e3ffe8f2a3f73840e1b42fd07299';
233
+ const REBASE_COMMIT_HASH = '9059ae0ca31caa2eebc035f2542842d6c2fde83b';
234
+ let sandboxPath;
235
+ beforeAll(async () => {
236
+ sandboxPath = (0, sandbox_1.getSandboxPath)({
237
+ filename: __filename,
238
+ specname: 'different-merge-strategies',
239
+ });
240
+ await (0, sandbox_1.resetSandbox)(sandboxPath);
241
+ await childProcess.exec('git clone https://github.com/backport-org/different-merge-strategies.git ./', { cwd: sandboxPath });
242
+ });
243
+ describe('getIsMergeCommit', () => {
244
+ it('returns true for first merge commit', async () => {
245
+ const res = await (0, git_1.getIsMergeCommit)({ dir: sandboxPath }, MERGE_COMMIT_HASH_1);
246
+ expect(res).toBe(true);
247
+ });
248
+ it('returns true for second merge commit', async () => {
249
+ const res = await (0, git_1.getIsMergeCommit)({ dir: sandboxPath }, MERGE_COMMIT_HASH_2);
250
+ expect(res).toBe(true);
251
+ });
252
+ it('returns false for rebased commits', async () => {
253
+ const res = await (0, git_1.getIsMergeCommit)({ dir: sandboxPath }, REBASE_COMMIT_HASH);
254
+ expect(res).toBe(false);
255
+ });
256
+ it('returns false for squashed commits', async () => {
257
+ const res = await (0, git_1.getIsMergeCommit)({ dir: sandboxPath }, SQUASH_COMMIT_HASH);
258
+ expect(res).toBe(false);
259
+ });
260
+ });
261
+ describe('getCommitsInMergeCommit', () => {
262
+ it('returns a list of commit hashes - excluding the merge hash itself', async () => {
263
+ const res = await (0, git_1.getCommitsInMergeCommit)({ dir: sandboxPath }, MERGE_COMMIT_HASH_1);
264
+ expect(res).not.toContain(MERGE_COMMIT_HASH_1);
265
+ expect(res).toEqual([
266
+ 'f9a760e0d9eb3ebcc64f8cb75ce885714b836496',
267
+ '7b92e29e88266004485ce0fae0260605b01df887',
268
+ 'a1facf8c006fb815d6a6ecd1b2907e6e64f29576',
269
+ 'b8d4bcfb0fd875be4ab0230f6db40ddf72f45378',
270
+ '6f224054db5f7772b04f23f17659070216bae84c',
271
+ '7fed54cbd1ba9cb973462670ff82ac80bf8a79f8',
272
+ '78c24d0058859e7d511d10ce91ebf279c7b58ac2',
273
+ '709ccf707d443dd8c001b3c3ae40fdf037bb43f5',
274
+ ]);
275
+ });
276
+ it('returns empty for squash commits', async () => {
277
+ const res = await (0, git_1.getCommitsInMergeCommit)({ dir: sandboxPath }, SQUASH_COMMIT_HASH);
278
+ expect(res).toEqual([]);
279
+ });
280
+ });
281
+ });
282
+ });
283
+ async function createAndCommitFile({ filename, content, execOpts, }) {
284
+ await childProcess.exec(`echo "${content}" > "${filename}"`, execOpts);
285
+ await childProcess.exec(`git add -A && git commit -m 'Update ${filename}'`, execOpts);
286
+ return getCurrentSha(execOpts);
287
+ }
288
+ async function getCurrentSha(execOpts) {
289
+ const { stdout } = await childProcess.exec('git rev-parse HEAD', execOpts);
290
+ return stdout.trim();
291
+ }
292
+ async function getCurrentMessage(execOpts) {
293
+ const { stdout } = await childProcess.exec('git --no-pager log -1 --pretty=%B', execOpts);
294
+ return stdout.trim();
295
+ }
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
+ }
@@ -99,9 +99,11 @@ async function getRepoInfoFromGitRemotes({ cwd }) {
99
99
  }
100
100
  }
101
101
  exports.getRepoInfoFromGitRemotes = getRepoInfoFromGitRemotes;
102
- async function getGitProjectRoot({ cwd }) {
102
+ async function getGitProjectRoot(dir) {
103
103
  try {
104
- const { stdout } = await (0, child_process_promisified_1.exec)('git rev-parse --show-toplevel', { cwd });
104
+ const { stdout } = await (0, child_process_promisified_1.exec)('git rev-parse --show-toplevel', {
105
+ cwd: dir,
106
+ });
105
107
  return stdout.trim();
106
108
  }
107
109
  catch (e) {
@@ -375,7 +377,7 @@ async function getSourceRepoPath(options) {
375
377
  const remoteUrl = getRemoteUrl(options, options.repoOwner);
376
378
  const sourcePath = options.repoName === gitRemote.repoName &&
377
379
  options.repoOwner === gitRemote.repoOwner
378
- ? (await getGitProjectRoot(options)) ?? remoteUrl
380
+ ? (await getGitProjectRoot(options.cwd)) ?? remoteUrl
379
381
  : remoteUrl;
380
382
  return sourcePath;
381
383
  }
@@ -0,0 +1 @@
1
+ export {};