Skip to content

Commit

Permalink
Merge branch 'main' into pipeline-escape-hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal authored Oct 4, 2024
2 parents 36ae7fd + 480d228 commit 54e912c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/config-file-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Example:
#### `accessToken` **required**

Personal access token.
Access tokens can be created here: https://github.com/settings/tokens
Access tokens can be created in the [GitHub Developer Settings, Personal Access Tokens, Tokens (classic)](https://github.com/settings/tokens/new?description=backport%20cli&scopes=repo,workflow)

Please select the necessary access scopes:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"branches",
"branching"
],
"version": "9.6.0",
"version": "9.6.1",
"main": "./dist/entrypoint.api.js",
"types": "dist/entrypoint.api.d.ts",
"bin": {
Expand Down
18 changes: 15 additions & 3 deletions src/lib/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ describe('deleteRemote', () => {
repoName: 'kibana',
} as ValidConfigOptions;

it('should swallow "no such remote" error', async () => {
it('should swallow "no such remote" error on git before 2.30.0', async () => {
const err = new childProcess.SpawnError({
code: 2,
code: 128,
cmdArgs: [],
stdout: '',
stderr: "fatal: No such remote: 'my-remote'\n",
Expand All @@ -376,11 +376,23 @@ describe('deleteRemote', () => {
await expect(await deleteRemote(options, remoteName)).toBe(undefined);
});

it('should swallow "no such remote" error, even if it is not in English', async () => {
it('should swallow "no such remote" error on git 2.30.0 or later', async () => {
const err = new childProcess.SpawnError({
code: 2,
cmdArgs: [],
stdout: '',
stderr: "fatal: No such remote: 'my-remote'\n",
});

jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
await expect(await deleteRemote(options, remoteName)).toBe(undefined);
});

it('should swallow "no such remote" error on git 2.30.0+, even if it is not in English', async () => {
const err = new childProcess.SpawnError({
code: 2, // returned only by git 2.30.0 or later, earlier versions returned 128
cmdArgs: [],
stdout: '',
stderr: "Fehler: Remote-Repository nicht gefunden: 'my-remote'\n",
});

Expand Down
13 changes: 9 additions & 4 deletions src/lib/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,15 @@ export async function deleteRemote(
} catch (e) {
const isSpawnError = e instanceof SpawnError;

// Swallow the "remote does not exist" failure, indicated by a return
// code of 2. From `git help remote`: "When subcommands such as add, rename,
// and remove can’t find the remote in question, the exit status is 2."
if (isSpawnError && e.context.code == 2) {
// Swallow the "remote does not exist" failure.
// Since git 2.30.0, this failure is indicated by the specific exit code 2.
// In earlier versions, the exit code is 128 and only the error message can
// tell the problems apart.
if (
isSpawnError &&
(e.context.code == 2 ||
(e.context.code == 128 && e.context.stderr.includes('No such remote')))
) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getDevAccessToken } from '../../private/getDevAccessToken';
import { getSandboxPath, resetSandbox } from '../../sandbox';
import { runBackportViaCli } from './runBackportViaCli';

jest.setTimeout(15_000);
jest.setTimeout(25_000);
const accessToken = getDevAccessToken();
const octokit = new Octokit({ auth: accessToken });

Expand Down
2 changes: 1 addition & 1 deletion src/utils/packageVersion.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const PACKAGE_VERSION = '9.6.0';
export const PACKAGE_VERSION = '9.6.1';

0 comments on commit 54e912c

Please sign in to comment.