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

Check if the clone target directory already exists. #369

Merged
merged 4 commits into from
Jun 22, 2016

Conversation

grokys
Copy link
Contributor

@grokys grokys commented Jun 16, 2016

And show a validation error if it doesn't. Fixes #360.

And show a validation error if it doesn't. Fixes #360.
Rather than .git/HEAD.
.IfTrue(x => x.Length > 200, "Path too long")
.IfContainsInvalidPathChars("Path contains invalid characters")
.IfPathNotRooted("Please enter a valid path")
.IfTrue(IsAlreadyRepoAtPath, Resources.RepositoryNameValidatorAlreadyExists);
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of copying this here, maybe it's best to pass an observable to CreateBaseRepositoryPathValidator. The repository creation viewmodel also does these exact same checks, it would be nice not to duplicate code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked into that, but it was just different enough to cause problems so I gave up and did it like this. I can look into it again though.

Copy link
Contributor

Choose a reason for hiding this comment

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

The only two differences are that this one takes an observable and the other one makes its own observable, so we can just pass in one instead of letting it do that; and that there's an extra IsTrue directive on this one, which can be added to the extension method since both create and clone should be doing the same validations. Everything else is the same, am I missing something?

Copy link
Contributor Author

@grokys grokys Jun 16, 2016

Choose a reason for hiding this comment

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

The issue was that in the create view model the repository name is validated separately from the base path, whereas in the clone dialog we don't need to validate the name as it's already coming from GitHub. So the options were either merge the two validators in the create view model somehow or have two validators for a single textbox in clone. Or just do as I did, and not share the validation code. If that makes sense?

As we decided that it was clearer to write out validation conditions
explicitly in the VM.
@shana
Copy link
Contributor

shana commented Jun 22, 2016

@shana shana merged commit da0fe18 into master Jun 22, 2016
@shana shana deleted the fixes/360-validate-clone-directory-exists branch June 22, 2016 08:55
@shana shana restored the fixes/360-validate-clone-directory-exists branch June 22, 2016 08:55
@shana shana deleted the fixes/360-validate-clone-directory-exists branch July 8, 2016 14:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants