This repository was archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Remove empty directory when clone fails #2241
Merged
StanleyGoldman
merged 7 commits into
github:master
from
YuPeiHenry:2126-empty-directory-when-clone-fails
Feb 28, 2019
Merged
Remove empty directory when clone fails #2241
StanleyGoldman
merged 7 commits into
github:master
from
YuPeiHenry:2126-empty-directory-when-clone-fails
Feb 28, 2019
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Currently an empty directory will be created when trying to clone non-existant remote repo. - This commit adds an action to delete the repo directory if an exception occurs while cloning.
jcansdale
suggested changes
Feb 26, 2019
Collaborator
jcansdale
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much for the PR. We definitely need this! 😄
I've requested a few minor changes. 👍
test/GitHub.App.UnitTests/Services/RepositoryCloneServiceTests.cs
Outdated
Show resolved
Hide resolved
|
|
||
| operatingSystem.Directory.Received().CreateDirectory(@"c:\dev\bar"); | ||
| operatingSystem.Directory.Received().DeleteDirectory(@"c:\dev\bar"); | ||
| await vsGitServices.Received().Clone("https://github.com/failing/url", @"c:\dev\bar", true); |
Collaborator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you factor out "https://github.com/failing/url" and @"c:\dev\bar" into something like cloneUrl and clonePath?
Contributor
|
@YuPeiHenry thank you for your contribution! |
- Delete directory may throw errors, so log.Error should be called first.
- Assert.ThrowAsync statement have been shortened. - failing url and dev bar have been factored into clonePath and cloneUrl.
Contributor
Author
|
@jcansdale I have updated the PR to adopt your suggestions. |
RepositoryCloneServiceTests and Substitutes were getting too coupled. This commit makes RepositoryCloneServiceTests self contained.
jcansdale
approved these changes
Feb 28, 2019
StanleyGoldman
approved these changes
Feb 28, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ready for review.
fixes #2126 . Added unit test to check that directory is removed when clone fails.
The fix deletes the directory when an exception in RepositoryCloneService:Clone is caught.