backport 8.4.3 → 8.4.4

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.
@@ -12,7 +12,7 @@ export declare function spawnPromise(cmd: string, cmdArgs: string[], cwd: string
12
12
  stderr: string;
13
13
  stdout: string;
14
14
  }>;
15
- export declare const spawnOriginal: typeof childProcess.spawn;
15
+ export declare const spawnStream: (cmd: string, cmdArgs: ReadonlyArray<string>) => childProcess.ChildProcessWithoutNullStreams;
16
16
  export declare type SpawnErrorContext = {
17
17
  cmdArgs: string[];
18
18
  code: number;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SpawnError = exports.spawnOriginal = exports.spawnPromise = exports.exec = void 0;
6
+ exports.SpawnError = exports.spawnStream = exports.spawnPromise = exports.exec = void 0;
7
7
  const child_process_1 = __importDefault(require("child_process"));
8
8
  const util_1 = require("util");
9
9
  const logger_1 = require("./logger");
@@ -12,6 +12,8 @@ async function exec(cmd, options) {
12
12
  const res = await execPromisified(cmd, {
13
13
  maxBuffer: 100 * 1024 * 1024,
14
14
  ...options,
15
+ // ensure that git commands return english error messages
16
+ env: { ...process.env, LANG: 'en_US' },
15
17
  });
16
18
  return res;
17
19
  }
@@ -20,7 +22,11 @@ async function spawnPromise(cmd, cmdArgs, cwd) {
20
22
  const fullCmd = `${cmd} ${cmdArgs.join(' ')}`;
21
23
  logger_1.logger.info(`Running command: "${fullCmd}"`);
22
24
  return new Promise(function (resolve, reject) {
23
- const subprocess = child_process_1.default.spawn(cmd, cmdArgs, { cwd });
25
+ const subprocess = child_process_1.default.spawn(cmd, cmdArgs, {
26
+ cwd,
27
+ // ensure that git commands return english error messages
28
+ env: { ...process.env, LANG: 'en_US' },
29
+ });
24
30
  let stderr = '';
25
31
  let stdout = '';
26
32
  subprocess.stdout.on('data', (data) => {
@@ -45,7 +51,12 @@ async function spawnPromise(cmd, cmdArgs, cwd) {
45
51
  });
46
52
  }
47
53
  exports.spawnPromise = spawnPromise;
48
- exports.spawnOriginal = child_process_1.default.spawn;
54
+ const spawnStream = (cmd, cmdArgs) => {
55
+ return child_process_1.default.spawn(cmd, cmdArgs, {
56
+ env: { ...process.env, LANG: 'en_US' },
57
+ });
58
+ };
59
+ exports.spawnStream = spawnStream;
49
60
  class SpawnError extends Error {
50
61
  constructor(context) {
51
62
  const cmdArgs = context.cmdArgs.join(' ');
package/dist/lib/git.js CHANGED
@@ -17,7 +17,7 @@ exports.getRemoteUrl = getRemoteUrl;
17
17
  async function cloneRepo({ sourcePath, targetPath }, onProgress) {
18
18
  logger_1.logger.info(`Cloning repo from ${sourcePath} to ${targetPath}`);
19
19
  return new Promise((resolve, reject) => {
20
- const subprocess = (0, child_process_promisified_1.spawnOriginal)('git', [
20
+ const subprocess = (0, child_process_promisified_1.spawnStream)('git', [
21
21
  'clone',
22
22
  sourcePath,
23
23
  targetPath,
@@ -39,7 +39,7 @@ jest.unmock('del');
39
39
  jest.unmock('make-dir');
40
40
  const commitAuthor = { name: 'Soren L', email: 'soren@mail.dk' };
41
41
  const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
42
- describe('git.integration', () => {
42
+ describe('git.private', () => {
43
43
  describe('getIsCommitInBranch', () => {
44
44
  let firstSha;
45
45
  let secondSha;
@@ -80,6 +80,23 @@ describe('git.integration', () => {
80
80
  expect(isSecondCommitInBranch).toEqual(false);
81
81
  });
82
82
  });
83
+ describe('deleteRemote', () => {
84
+ const cwd = (0, sandbox_1.getSandboxPath)({
85
+ filename: __filename,
86
+ specname: 'deleteRemote',
87
+ });
88
+ it('should handle when deleting a remote that does not exist', async () => {
89
+ const options = {
90
+ repoName: 'kibana',
91
+ repoOwner: 'elastic',
92
+ dir: cwd,
93
+ };
94
+ await (0, sandbox_1.resetSandbox)(cwd);
95
+ await gitInit(cwd);
96
+ const res = await (0, git_1.deleteRemote)(options, 'my-remote-foo');
97
+ expect(res).toBe(undefined);
98
+ });
99
+ });
83
100
  describe('getGitConfig', () => {
84
101
  const cwd = (0, sandbox_1.getSandboxPath)({
85
102
  filename: __filename,
@@ -47,7 +47,7 @@ describe('setupRepo', () => {
47
47
  it('should delete repo', async () => {
48
48
  expect.assertions(2);
49
49
  jest
50
- .spyOn(childProcess, 'spawnOriginal')
50
+ .spyOn(childProcess, 'spawnStream')
51
51
  .mockImplementation((cmd, cmdArgs) => {
52
52
  if (cmdArgs.includes('clone')) {
53
53
  throw new Error('Simulated git clone failure');
@@ -74,7 +74,7 @@ describe('setupRepo', () => {
74
74
  .spyOn(gitModule, 'getLocalSourceRepoPath')
75
75
  .mockResolvedValue(undefined);
76
76
  jest
77
- .spyOn(childProcess, 'spawnOriginal')
77
+ .spyOn(childProcess, 'spawnStream')
78
78
  //@ts-expect-error
79
79
  .mockImplementation(() => {
80
80
  return {
@@ -194,7 +194,7 @@ describe('setupRepo', () => {
194
194
  });
195
195
  function mockGitClone() {
196
196
  jest
197
- .spyOn(childProcess, 'spawnOriginal')
197
+ .spyOn(childProcess, 'spawnStream')
198
198
  //@ts-expect-error
199
199
  .mockImplementation((cmd, cmdArgs) => {
200
200
  if (cmdArgs.includes('clone')) {
@@ -227,7 +227,7 @@ describe('setupRepo', () => {
227
227
  });
228
228
  it('should clone it from github.com', async () => {
229
229
  expect(spinnerSuccessSpy).toHaveBeenCalledWith('100% Cloning repository from github.com (one-time operation)');
230
- expect(childProcess.spawnOriginal).toHaveBeenCalledWith('git', [
230
+ expect(childProcess.spawnStream).toHaveBeenCalledWith('git', [
231
231
  'clone',
232
232
  'https://x-access-token:myAccessToken@github.com/elastic/kibana.git',
233
233
  '/myHomeDir/.backport/repositories/elastic/kibana',
@@ -256,7 +256,7 @@ describe('setupRepo', () => {
256
256
  });
257
257
  it('should clone it from local folder', async () => {
258
258
  expect(spinnerSuccessSpy).toHaveBeenCalledWith('100% Cloning repository from /path/to/source/repo (one-time operation)');
259
- expect(childProcess.spawnOriginal).toHaveBeenCalledWith('git', [
259
+ expect(childProcess.spawnStream).toHaveBeenCalledWith('git', [
260
260
  'clone',
261
261
  '/path/to/source/repo',
262
262
  '/myHomeDir/.backport/repositories/elastic/kibana',
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "8.4.3";
1
+ export declare const PACKAGE_VERSION = "8.4.4";
@@ -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 = '8.4.3';
4
+ exports.PACKAGE_VERSION = '8.4.4';
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "branches",
15
15
  "branching"
16
16
  ],
17
- "version": "8.4.3",
17
+ "version": "8.4.4",
18
18
  "main": "./dist/entrypoint.module.js",
19
19
  "types": "dist/entrypoint.module.d.ts",
20
20
  "bin": {