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

Commit 37d4790

Browse files
committed
Handle case where owner and repo have same name
1 parent 785c5f6 commit 37d4790

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/GitHub.App/ViewModels/Dialog/Clone/RepositoryCloneViewModel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ string GetUpdatedBasePath(string path)
175175

176176
string FindDirWithout(string dir, string match, int levels)
177177
{
178+
string dirWithout = null;
178179
for (var i = 0; i < 2; i++)
179180
{
180181
if (string.IsNullOrEmpty(dir))
@@ -186,11 +187,11 @@ string FindDirWithout(string dir, string match, int levels)
186187
dir = System.IO.Path.GetDirectoryName(dir);
187188
if (name == match)
188189
{
189-
return dir;
190+
dirWithout = dir;
190191
}
191192
}
192193

193-
return null;
194+
return dirWithout;
194195
}
195196
}
196197

test/GitHub.App.UnitTests/ViewModels/Dialog/Clone/RepositoryCloneViewModelTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ public async Task Repository_Name_Replaces_Last_Part_Of_Non_Base_Path()
174174
Description = "Base path cleared")]
175175
[TestCase("c:\\base", "owner1/repo1", "c:\\base\\repo1", "owner2/repo2", "c:\\base\\owner2\\repo2",
176176
Description = "Owner deleted")]
177+
[TestCase("c:\\base", "same/same", "c:\\base\\same\\same", "owner2/repo2", "c:\\base\\owner2\\repo2",
178+
Description = "Owner and repo have same name")]
177179
public async Task User_Edits_Path(string defaultClonePath, string repo1, string userPath, string repo2, string expectPath)
178180
{
179181
var target = CreateTarget(defaultClonePath: defaultClonePath);

0 commit comments

Comments
 (0)