Skip to content

Add additional regex pattern for HostDown error code - #308

Merged
shiftkey merged 5 commits into
desktop:masterfrom
Daniel-McCarthy:Add-New-Clone-Failed-Error-Regex-Pattern
Mar 4, 2019
Merged

shiftkey merged 5 commits into
desktop:masterfrom
Daniel-McCarthy:Add-New-Clone-Failed-Error-Regex-Pattern

Conversation

@Daniel-McCarthy

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

@shiftkey shiftkey left a comment

Copy link
Copy Markdown
Member

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

Comment thread test/fast/git-process-test.ts Outdated
})

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
Copy Markdown
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
Copy Markdown
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

shiftkey commented Mar 4, 2019

Copy link
Copy Markdown
Member

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.

@shiftkey shiftkey left a comment

Copy link
Copy Markdown
Member

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...

Comment thread lib/errors.ts 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 <[email protected]>
@shiftkey
shiftkey merged commit 6f3971f into desktop:master Mar 4, 2019
@shiftkey

shiftkey commented Mar 4, 2019

Copy link
Copy Markdown
Member

[email protected] 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
Copy Markdown
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.

2 participants