Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional regex pattern for HostDown error code #308

Conversation

Daniel-McCarthy
Copy link
Member

This pull request is made to assist Desktop's Issue #926 by adding a regex pattern to detect a cloning failure error. Currently the error is not being parsed due to not having a pattern that matches to it. The error in question occurs when attempting to clone a repository with no available internet connection.

The exact error to be detected is:
"Cloning into '/home/hellokitty/Documents/GitHub/Chixel'... fatal: unable to access 'https://github.com/Daniel-McCarthy/Chixel.git/': Could not resolve host: github.com"


In a comment it was suggested that this regular expression pattern should be added to target the same error type HostDown that is being used by a currently existing regex pattern. I have added a test to go along with checking the new regular expression pattern is parsing properly. However, I noticed there was not already one in place for the original HostDown error regex. I could add a test to go along with the original pattern as well in this pull request.

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.
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.
Copy link
Member

@shiftkey shiftkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one thing to ensure the test handles what Git emits

@@ -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/'... fatal: unable to access 'https://github.com/Daniel-McCarthy/dugite.git/': Could not resolve host: github.com"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to include the newline characters in this stderr output so we can confirm the regex is working as expected?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, good catch! I have updated both as appropriate.

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.
…r 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.
@shiftkey
Copy link
Member

shiftkey commented Mar 4, 2019

However, I noticed there was not already one in place for the original HostDown error regex. I could add a test to go along with the original pattern as well in this pull request.

Because this is an additive regex I'm fine to leave it as-is.

Copy link
Member

@shiftkey shiftkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty close to merging. One suggestion to relax the new regex...

lib/errors.ts Outdated Show resolved Hide resolved
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 <dan.willy.mccarthy@gmail.com>
@shiftkey shiftkey merged commit 6f3971f into desktop:master Mar 4, 2019
@shiftkey
Copy link
Member

shiftkey commented Mar 4, 2019

dugite@1.86.0 has been published to NPM with this change - thanks for the contribution @Daniel-McCarthy, and feel free to submit any extra PRs to help with your work on Desktop!

@Daniel-McCarthy Daniel-McCarthy deleted the Add-New-Clone-Failed-Error-Regex-Pattern branch March 4, 2019 22:51
@Daniel-McCarthy
Copy link
Member Author

@shiftkey That's awesome, thank you! I will definitely be keeping that in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants