Skip to content

Commit 03adbb4

Browse files
committed
Fix deleted items finding projects in sub folders
1 parent 90821ae commit 03adbb4

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

snippets5000/PullRequestSimulations/data.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@
6363
}
6464
]
6565
},
66+
{
67+
"Name": "Delete - Stray CS file, other projects below",
68+
"CountOfEmptyResults": 1,
69+
"ExpectedResults": null,
70+
"Items": [
71+
{
72+
"ItemType": "Delete",
73+
"Path": "snippets/good/deeper-path/codefile.cs"
74+
}
75+
]
76+
},
6677
{
6778
"Name": "Create - New proj, find sln",
6879
"ExpectedResults": [

snippets5000/Snippets5000/Properties/launchSettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"Test via GitHub": {
44
"commandName": "Project",
5-
"commandLineArgs": "--sourcepath C:\\Users\\wiwagn\\source\\docs --owner dotnet --repo docs --pullrequest 38723",
5+
"commandLineArgs": "--sourcepath C:\\Users\\adegeo\\code\\dotnet-api-docs --owner dotnet --repo dotnet-api-docs --pullrequest 11502",
66
"environmentVariables": {
77
"ExtensionsProjs": ".csproj;.fsproj;.vbproj;.vcxproj;.sln",
88
"ExtensionsCodeTriggers": ".cs;.vb;.fs;.cpp;.h;.xaml;.razor;.cshtml;.vbhtml",
@@ -21,4 +21,4 @@
2121
}
2222
}
2323
}
24-
}
24+
}

snippets5000/Snippets5000/PullRequestProcessor.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private async IAsyncEnumerable<DiscoveryResult> FindAllSolutionsAndProjects(stri
9191
return null;
9292

9393
// Check for the project/solution to test with was found
94-
FindProjectOrSolution(rootDir, itemPath, out string? project, out int countOfSln, out int countOfProjs, out int countOfCode, out int countOfSpecial, ref projectsFound);
94+
FindProjectOrSolution(rootDir, itemPath, itemWasDeleted, out string? project, out int countOfSln, out int countOfProjs, out int countOfCode, out int countOfSpecial, ref projectsFound);
9595

9696
// If it's a solution file, check that all the projects are referenced in it:
9797
if (countOfSln == 1)
@@ -134,7 +134,7 @@ private async IAsyncEnumerable<DiscoveryResult> FindAllSolutionsAndProjects(stri
134134
};
135135
}
136136

137-
static void FindProjectOrSolution(string rootDir, string itemDirectory, out string? project, out int countOfSln, out int countOfProjs, out int countOfCode, out int countOfSpecial, ref List<string> projectsFound)
137+
static void FindProjectOrSolution(string rootDir, string itemDirectory, bool isDeleted, out string? project, out int countOfSln, out int countOfProjs, out int countOfCode, out int countOfSpecial, ref List<string> projectsFound)
138138
{
139139
project = null;
140140
countOfSln = 0;
@@ -146,7 +146,8 @@ static void FindProjectOrSolution(string rootDir, string itemDirectory, out stri
146146
// If a file is deleted, and no other content is there, the directory won't exist
147147
if (Directory.Exists(itemDirectory))
148148
{
149-
foreach (var file in Directory.EnumerateFiles(itemDirectory, $"*.*", SearchOption.AllDirectories))
149+
// If the item is deleted, we don't need to scan it, but we do need to scan the parents
150+
foreach (var file in Directory.EnumerateFiles(itemDirectory, $"*.*", isDeleted ? SearchOption.TopDirectoryOnly : SearchOption.AllDirectories))
150151
ScanFile(file, ref project, ref countOfSln, ref countOfProjs, ref countOfCode, ref countOfSpecial, ref projectsFound);
151152
}
152153

0 commit comments

Comments
 (0)