From 29b23b4ad8fb9aba9e11c272dc89176181669616 Mon Sep 17 00:00:00 2001 From: Sergio Padrino Date: Mon, 13 May 2024 11:42:55 +0200 Subject: [PATCH] Parse auth errors for HTTP repos --- lib/errors.ts | 2 +- test/fast/git-process-test.ts | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/errors.ts b/lib/errors.ts index 3f1b10bf..0c085e18 100644 --- a/lib/errors.ts +++ b/lib/errors.ts @@ -69,7 +69,7 @@ export const GitErrorRegexes: { [regexp: string]: GitError } = { GitError.BadConfigValue, 'ERROR: ([\\s\\S]+?)\\n+\\[EPOLICYKEYAGE\\]\\n+fatal: Could not read from remote repository.': GitError.SSHKeyAuditUnverified, - "fatal: Authentication failed for 'https://": + "fatal: Authentication failed for 'https?://": GitError.HTTPSAuthenticationFailed, 'fatal: Authentication failed': GitError.SSHAuthenticationFailed, 'fatal: Could not read from remote repository.': GitError.SSHPermissionDenied, diff --git a/test/fast/git-process-test.ts b/test/fast/git-process-test.ts index af591204..dc792abc 100644 --- a/test/fast/git-process-test.ts +++ b/test/fast/git-process-test.ts @@ -287,7 +287,21 @@ describe('git-process', () => { expect((error as any).code).toBe(RepositoryDoesNotExistErrorCode) }) - it('can parse errors', () => { + it('can parse HTTPS auth errors', () => { + const error = GitProcess.parseError( + "fatal: Authentication failed for 'https://www.github.com/shiftkey/desktop.git/'" + ) + expect(error).toBe(GitError.HTTPSAuthenticationFailed) + }) + + it('can parse HTTP auth errors', () => { + const error = GitProcess.parseError( + "fatal: Authentication failed for 'http://localhost:3000'" + ) + expect(error).toBe(GitError.HTTPSAuthenticationFailed) + }) + + it('can parse SSH auth errors', () => { const error = GitProcess.parseError('fatal: Authentication failed') expect(error).toBe(GitError.SSHAuthenticationFailed) })