Skip to content

Commit

Permalink
Merge pull request #560 from desktop/parse-http-auth-errors
Browse files Browse the repository at this point in the history
Parse auth errors for HTTP repos
  • Loading branch information
sergiou87 authored May 14, 2024
2 parents 6915785 + 29b23b4 commit 8e845ff
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 8e845ff

Please sign in to comment.