From 6f3971f75e4d7e11a102f1a69ea2380054e5f078 Mon Sep 17 00:00:00 2001 From: Dan McCarthy Date: Mon, 4 Mar 2019 16:40:49 -0600 Subject: [PATCH] Add additional regex pattern for HostDown error code (#308) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added new regex pattern to detect HostDown errors An error in GitHub Desktop was being thrown that was not being appropriately parsed. In order to properly catch it a new regular expression pattern has been added. * Added test to check parsing for could not resolve host error An exra regular expression pattern was added to detect a Git.HostDown error. In order to make sure it is parsing correctly a test has been added. * Updated New HostDown regex & test with new line characters Previously the test and regex were missing the "↵" newline characters where appropriate. They have been added to match the original error's placement of new line characters. * Updated HostDown regex and test string to use correct escape character newline Previously a commit was added to properly handle newline characters. The characters used however are not newline escape characters. They have been updated to fix the previous issue. * Simplify HostDown Regex by ignoring final newline character Detecting the final newline character is not essential for the match to be made, therefore we can safely remove it. Co-Authored-By: Daniel-McCarthy --- lib/errors.ts | 2 ++ test/fast/git-process-test.ts | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lib/errors.ts b/lib/errors.ts index cd6d33e5..f7d7eb14 100644 --- a/lib/errors.ts +++ b/lib/errors.ts @@ -61,6 +61,8 @@ export const GitErrorRegexes = { 'The requested URL returned error: 403': GitError.HTTPSAuthenticationFailed, 'fatal: The remote end hung up unexpectedly': GitError.RemoteDisconnection, "fatal: unable to access '(.+)': Failed to connect to (.+): Host is down": GitError.HostDown, + "Cloning into '(.+)'...\nfatal: unable to access '(.+)': Could not resolve host: (.+)": + GitError.HostDown, 'Failed to merge in the changes.': GitError.RebaseConflicts, '(Merge conflict|Automatic merge failed; fix conflicts and then commit the result)': GitError.MergeConflicts, diff --git a/test/fast/git-process-test.ts b/test/fast/git-process-test.ts index 223b9b73..04d89d1c 100644 --- a/test/fast/git-process-test.ts +++ b/test/fast/git-process-test.ts @@ -423,5 +423,12 @@ mark them as resolved using git add` const error = GitProcess.parseError(stderr) expect(error).toBe(GitError.UnresolvedConflicts) }) + + it('can parse the could not resolve host error', () => { + const stderr = `"Cloning into '/cloneablepath/'...\nfatal: unable to access 'https://github.com/Daniel-McCarthy/dugite.git/': Could not resolve host: github.com\n"` + + const error = GitProcess.parseError(stderr) + expect(error).toBe(GitError.HostDown) + }) }) })