-
Notifications
You must be signed in to change notification settings - Fork 1k
[Version Control] Avoid creating .git if it already exists #7354
base: main
Are you sure you want to change the base?
Conversation
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.
Just wondering if we could/should make this logic available to the New Project dialog so it could disable the Git options before it reaches this code.
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.
Currently the New Project dialog enables/disables the git checkbox here -
monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs
Line 287 in 40d52a9
finalConfigurationPage.IsUseGitEnabled = IsNewSolution && (versionControlHandler != null); |
Either the logic could be moved into the New Project dialog or the IVersionControlProjectTemplateHandler could be extended with a new method which the New Project dialog could call to see if git can be enabled.
I guess one problem here is that the logic is dependent on where the solution is being created. So after the location is changed the new project dialog would need to check to see if the git checkbox should be enabled/disabled. Currently this check is just done the one time.
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.
I like this idea, lets's add a IVersionControlProjectTemplateHandler.CanCreateRepository (FilePath atPath)
. FinalProjectConfigurationPage
could have an additional ParentFolderChanged
event and the NewProjectController
would subscribe to that and set IsUseGitEnabled
based on the result of CanCreateRepository.
Matt, I liked your idea. Thanks guys for the feedback!. I have made changes to disable the Git option if a .git folder already exists (in the selected path). |
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.
I'm not sure about the warning, I think VS on Windows doesn't tell anything or does it?
About Gitignore: I'd say let's keep it as is. Because a gitignore can live inside a subfolder. Of course we could check if it exists or not, but this would require additional interface changes, which is already not very clean (the API pretends to be generic for all VCS systems, but the UI refers to git only, and Gitignore is git specific, hence we would really need to rewrite this whole thing).
I'd propose to do the check in ProjectTemplateHandler.cs where it actually creates that file: if it exists, just skip it, if not create it in the NEW PROJECT/SOLUTION folder (not repo root).
...trol/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/ProjectTemplateHandler.cs
Outdated
Show resolved
Hide resolved
main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/GtkProjectConfigurationWidget.cs
Outdated
Show resolved
Hide resolved
91fa09a
to
44dc1f8
Compare
497d524
to
77795d8
Compare
main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs
Outdated
Show resolved
Hide resolved
@@ -179,7 +182,7 @@ public string GetValidSolutionName () | |||
} | |||
|
|||
public bool IsGitIgnoreEnabled { | |||
get { return config.UseGit && IsUseGitEnabled && gitIgnoreEnabled; } | |||
get { return config.UseGit && gitIgnoreEnabled && EnableCreateGitIgnore(); } | |||
} |
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.
Can we add tests for this new logic?
There are some tests for the IsGitIgnoreEnabled flag in the NewProjectDialogTests.
Also should the IsUseGitEnabled check be removed here? That is used
monodevelop/main/tests/Ide.Tests/MonoDevelop.Ide.Projects/NewProjectDialogTests.cs
Line 273 in f9839cd
Assert.IsFalse (controller.FinalConfiguration.IsGitIgnoreEnabled); |
The behavior with .gitignore with this changes:
|
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.
Just the EventArgs thing :).
Hey @mkrueger, thanks for the feedback but, what do you mean by the |
@jsuarezruiz I think @mkrueger meant to use |
Ah, ok!. Changed. Thanks guys. |
main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/FinalProjectConfigurationPage.cs
Outdated
Show resolved
Hide resolved
…ior when creating a new project with git in a folder that's already a git repo
When creating a new project into a folder which already has already been setup as a git repo, avoid create the .git folder.
Fixes VSTS #660470