Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Conversation

@YuPeiHenry
Copy link
Contributor

@YuPeiHenry YuPeiHenry commented Feb 26, 2019

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.

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

@jcansdale jcansdale left a 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. 👍


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);
Copy link
Collaborator

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?

@meaghanlewis
Copy link
Contributor

@YuPeiHenry thank you for your contribution!

@meaghanlewis meaghanlewis added this to the 2.9.0 milestone Feb 26, 2019
YuPeiHenry and others added 3 commits February 27, 2019 09:52
- 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.
@YuPeiHenry
Copy link
Contributor Author

@jcansdale I have updated the PR to adopt your suggestions.

YuPeiHenry and others added 2 commits February 28, 2019 09:59
RepositoryCloneServiceTests and Substitutes were getting too coupled.
This commit makes RepositoryCloneServiceTests self contained.
@StanleyGoldman StanleyGoldman merged commit 0054884 into github:master Feb 28, 2019
@github github deleted a comment Feb 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't leave behind empty directory when a clone fails

4 participants