GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allow cloning of repositories into empty directories by YuPeiHenry · Pull Request #2316 · github/VisualStudio

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

Conversation

@YuPeiHenry

@YuPeiHenry YuPeiHenry commented Apr 4, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Ready for review
fixes #2250

The fix modifies CanClone and CanOpen on RepositoryCloneViewModel, and modified RepositoryCloneService CloneOrOpenRepository method to factor for empty directories.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
YuPeiHenry added 2 commits April 4, 2019 20:11
@YuPeiHenry
Enable clone and disable open button on empty dir.
7c998ec
- Currently clone button is disabled and open button is enabled
on empty directories.
- Desired behavior should support cloning to empty directories.
- Non-empty directory message is not shown when the directory is empty.
@YuPeiHenry
Add support for cloning into empty dir.
b7cd425
jcansdale
jcansdale suggested changes Apr 4, 2019
View reviewed changes

@jcansdale jcansdale left a comment

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

This is looking good!

Could you add some unit tests? Something similar to this...
https://github.com/github/VisualStudio/blob/master/test/GitHub.App.UnitTests/ViewModels/Dialog/Clone/RepositoryCloneViewModelTests.cs#L317

Maybe add the following tests:

Clone_Is_Enabled_When_Path_EmptyDirectoryExists
PathWarning_Is_Not_Set_When_EmptyDirectoryExists_Selected

I've just realized this is a draft PR. Sorry if I've jumped the gun reviewing it. ;-)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/GitHub.App/ViewModels/Dialog/Clone/RepositoryCloneViewModel.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@YuPeiHenry
Add tests for CloneService with empty directory.
1618a86
@YuPeiHenry
YuPeiHenry marked this pull request as ready for review April 4, 2019 14:39
@YuPeiHenry
RepositoryCloneViewModel: Combine if condition.
43b5ef6
@YuPeiHenry
YuPeiHenry force-pushed the 2250-allow-cloning-to-empty-dir branch from 80198b4 to 43b5ef6 Compare April 4, 2019 15:01
YuPeiHenry added 2 commits April 4, 2019 23:04
@YuPeiHenry
Add tests for RespositoryCloneViewModel on empty directory.
933a105
@YuPeiHenry
Ammend some tests in RepositoryCloneServiceTests to not use data.
37b05a7
@meaghanlewis
meaghanlewis requested a review from jcansdale April 4, 2019 20:05
@YuPeiHenry
Merge branch 'master' into 2250-allow-cloning-to-empty-dir
96d3844
jcansdale
jcansdale approved these changes Apr 5, 2019
View reviewed changes
jcansdale
jcansdale approved these changes Apr 5, 2019
View reviewed changes

@jcansdale jcansdale left a comment

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

The code for this looks good! 😄 We just need someone to confirm the functionality.

Thanks for the PR!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
StanleyGoldman and others added 2 commits April 5, 2019 12:37
@StanleyGoldman
Merge branch 'master' into 2250-allow-cloning-to-empty-dir
382969b
@jcansdale
Merge branch 'master' into 2250-allow-cloning-to-empty-dir
c82ca09
StanleyGoldman
StanleyGoldman suggested changes Apr 5, 2019
View reviewed changes

@StanleyGoldman StanleyGoldman left a comment

Copy link
Copy Markdown
Contributor

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.

We probably need to make the error/warning messages clearer...

For instance when I'm trying to clone into a directory that is not empty and does not have a git repo
The message says "There is already a repository at this location, but it does not contain a repository".

That's not entirely accurate, I haven't looked but I think we have to re-evaluate the messages output by the view model in this and probably some other cases.

image

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@StanleyGoldman

StanleyGoldman commented Apr 5, 2019

Copy link
Copy Markdown
Contributor

image

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@StanleyGoldman

StanleyGoldman commented Apr 5, 2019

Copy link
Copy Markdown
Contributor

The more I look at it, it's just that one message that would no longer be accurate...
I don't even think it was right to begin with..

If the directory is not empty, and is not a git repo that could be scanned.
The error message probably should have been. "A directory exists at the destination path."
Similar to "A file exists at the destination path."

Based on the current logic in this Pull Request.
The new error message should be: "The directory at the destination path is not empty."
The chain of logic should be... (in pseudocode)

if file_exists_at_destination:
   return "A file exists at the destination path"

else:
   if directory_exists_at_destination AND directory_at_destination_not_empty:

      if directory_exists_at_destination_is_git_repo:
         if git_repo_has_no_origin:
            return "A repository already exists at this location, but it doesn't have a remote named `origin`."
         end if

         if git_repo_origin_is_different:
            return "A repository already exists at this location, but it doesn't have a remote named `origin`."
         end if

      else:
         return "The directory at the destination path is not empty."
      end if

   end if
end if
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@StanleyGoldman

StanleyGoldman commented Apr 5, 2019

Copy link
Copy Markdown
Contributor

Let @meaghanlewis weigh in before you change anything...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@meaghanlewis

meaghanlewis commented Apr 5, 2019

Copy link
Copy Markdown
Contributor

I agree with what @StanleyGoldman proposed: The directory at the destination path is not empty. Its straightforward and covers cases where there might be a git directory for the destination or not.

jcansdale reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

YuPeiHenry and others added 2 commits April 7, 2019 20:46
@YuPeiHenry
Update error message for non-empty directory.
473373c
@YuPeiHenry
Merge branch 'master' into 2250-allow-cloning-to-empty-dir
83095d5
@YuPeiHenry

YuPeiHenry commented Apr 7, 2019

Copy link
Copy Markdown
Contributor Author

@StanleyGoldman I have updated the error message for non-empty directory. Should something be done about the translation to other languages in this PR?

meaghanlewis reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

StanleyGoldman added 4 commits April 8, 2019 08:17
@StanleyGoldman
Copying english to all resources
cb81d03
@StanleyGoldman
Simplifying logic
68d7c8f
@StanleyGoldman
DestinationDirectoryEmpty is (should be) used responsibly and not cal…
1d8e3e8
…led on directories that don't exist
@StanleyGoldman
Update Resources.resx
ef0ed57
@StanleyGoldman
StanleyGoldman force-pushed the 2250-allow-cloning-to-empty-dir branch from a29268a to ef0ed57 Compare April 8, 2019 12:42
@StanleyGoldman

StanleyGoldman commented Apr 8, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Hey @YuPeiHenry I pushed some commits. It felt easier than nit picking at you. 😈

So I copied the English text to all the language files, we have a 3rd party resource that translates things for us. So we just put the English in place until they get around to it.

I also realized I reordered the logic funny in my pseudocode. You changed the flow to match my ramblings. I undid the damage I caused. Sorry to put you through my spaghetti brain.

And I tweaked DestinationDirectoryEmpty. Everywhere that the function is used, we explicitly check if the directory exists. It makes sense to check if the directory exists inside DestinationDirectoryEmpty to prevent an error, but it's also redundant to all the code that uses DestinationDirectoryEmpty. The only correct choice is to assume the function with be used properly.

All nit picks. I didn't wanna bug you with it. 😅

Since my hands have been all in this, I'm going to let @meaghanlewis test this and give us both the final approval.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

StanleyGoldman
StanleyGoldman approved these changes Apr 8, 2019
View reviewed changes
@StanleyGoldman
StanleyGoldman requested a review from meaghanlewis April 8, 2019 14:06
meaghanlewis
meaghanlewis approved these changes Apr 8, 2019
View reviewed changes
@meaghanlewis

meaghanlewis commented Apr 8, 2019

Copy link
Copy Markdown
Contributor

thank you @YuPeiHenry for your contribution! 🎉

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@meaghanlewis
meaghanlewis merged commit 285c8a5 into github:master Apr 8, 2019
@StanleyGoldman StanleyGoldman mentioned this pull request Apr 10, 2019
Fixing the error with the clone button #2322
Merged
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

3 more reviewers
@StanleyGoldman StanleyGoldman StanleyGoldman approved these changes
@meaghanlewis meaghanlewis meaghanlewis approved these changes
@jcansdale jcansdale jcansdale approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Allow cloning of repositories into empty directories

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@YuPeiHenry @StanleyGoldman @meaghanlewis @jcansdale
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.