Skip to content

Commit

Permalink
Fixed directory matching
Browse files Browse the repository at this point in the history
  • Loading branch information
maca88 committed Oct 4, 2017
1 parent 1f13298 commit e5ba128
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Shared/FileMatcher.cs
Expand Up @@ -296,7 +296,7 @@ string pattern
directories = Directory.EnumerateDirectories((path.Length == 0) ? s_thisDirectory : path, pattern);
if (ShouldEnforceMatching(pattern))
{
directories = directories.Where(o => IsMatch(Path.GetDirectoryName(o), pattern));
directories = directories.Where(o => IsMatch(Path.GetFileName(o), pattern));
}
}

Expand Down Expand Up @@ -824,7 +824,7 @@ TaskOptions taskOptions
for (int i = 0; i < excludeNextSteps.Length; i++)
{
if (excludeNextSteps[i].NeedsDirectoryRecursion &&
(excludeNextSteps[i].DirectoryPattern == null || IsMatch(Path.GetDirectoryName(subdir), excludeNextSteps[i].DirectoryPattern)))
(excludeNextSteps[i].DirectoryPattern == null || IsMatch(Path.GetFileName(subdir), excludeNextSteps[i].DirectoryPattern)))
{
RecursionState thisExcludeStep = searchesToExclude[i];
thisExcludeStep.BaseDirectory = subdir;
Expand Down
30 changes: 30 additions & 0 deletions src/Shared/UnitTests/FileMatcher_Tests.cs
Expand Up @@ -1194,6 +1194,36 @@ public void ExcludePatternAndSpecificFiles()
@"src\Common\Properties\AssemblyInfo.cs",
}
)]
[InlineData(
@"**\*.cs", // Include Pattern
new[] // Exclude patterns
{
@"**\bin\**\*.cs",
@"src\Co??on\**",
},
new[] // Matching files
{
@"foo.cs",
@"src\Framework\Properties\AssemblyInfo.cs",
@"src\Framework\Foo\Bar\Baz\Buzz.cs"
},
new[] // Non matching files
{
@"foo.txt",
@"src\Framework\Readme.md",
@"src\Common\foo.cs",
// Ideally these would be untouchable
@"src\Framework\bin\foo.cs",
@"src\Framework\bin\Debug",
@"src\Framework\bin\Debug\foo.cs",
@"src\Common\Properties\AssemblyInfo.cs"
},
new[] // Non matching files that shouldn't be touched
{
@"src\Common\Properties\"
}
)]
[InlineData(
@"src\**\proj\**\*.cs", // Include Pattern
new[] // Exclude patterns
Expand Down

0 comments on commit e5ba128

Please sign in to comment.