Skip to content

Commit

Permalink
Parse auth errors for HTTP repos
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiou87 committed May 13, 2024
1 parent 6915785 commit 29b23b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 15 additions & 1 deletion test/fast/git-process-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down

0 comments on commit 29b23b4

Please sign in to comment.