diff --git a/OneWare.sln b/OneWare.sln index b0787493..9a1e1045 100644 --- a/OneWare.sln +++ b/OneWare.sln @@ -135,6 +135,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneWare.NetListSvgIntegrati EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneWare.NetListSvgIntegration.UnitTests", "tests\OneWare.NetListSvgIntegration.UnitTests\OneWare.NetListSvgIntegration.UnitTests.csproj", "{89668C99-1F29-453B-828C-D89EBA9EA218}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneWare.Shared.UnitTests", "tests\OneWare.Shared.UnitTests\OneWare.Shared.UnitTests.csproj", "{5C6FFAFA-590C-400D-8F90-89C9880864AF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -293,6 +295,10 @@ Global {89668C99-1F29-453B-828C-D89EBA9EA218}.Debug|Any CPU.Build.0 = Debug|Any CPU {89668C99-1F29-453B-828C-D89EBA9EA218}.Release|Any CPU.ActiveCfg = Release|Any CPU {89668C99-1F29-453B-828C-D89EBA9EA218}.Release|Any CPU.Build.0 = Release|Any CPU + {5C6FFAFA-590C-400D-8F90-89C9880864AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5C6FFAFA-590C-400D-8F90-89C9880864AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5C6FFAFA-590C-400D-8F90-89C9880864AF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5C6FFAFA-590C-400D-8F90-89C9880864AF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {F08B36E8-AB80-42CD-BD47-6B05E96DA390} = {0761690C-7DA0-4554-9F6B-211088412DCD} @@ -336,5 +342,6 @@ Global {4E2FD886-862B-4DE9-A69E-AE82E52979B5} = {BD761CED-3D61-4D9E-A2A1-494584F2ED5F} {C3A5837C-6679-493A-A6FD-F3440AF57FDE} = {BD761CED-3D61-4D9E-A2A1-494584F2ED5F} {89668C99-1F29-453B-828C-D89EBA9EA218} = {EB783E04-C3C8-45F8-B810-24798DAE2450} + {5C6FFAFA-590C-400D-8F90-89C9880864AF} = {EB783E04-C3C8-45F8-B810-24798DAE2450} EndGlobalSection EndGlobal diff --git a/src/OneWare.Shared/Helpers/ProjectHelper.cs b/src/OneWare.Shared/Helpers/ProjectHelper.cs index d2cdb559..275ac546 100644 --- a/src/OneWare.Shared/Helpers/ProjectHelper.cs +++ b/src/OneWare.Shared/Helpers/ProjectHelper.cs @@ -1,4 +1,5 @@ using System.IO.Enumeration; +using OneWare.Shared.Extensions; using OneWare.Shared.Models; namespace OneWare.Shared.Helpers; @@ -46,6 +47,9 @@ public static void ImportEntries(string source, IProjectFolder destination) public static bool MatchWildCards(string path, IEnumerable include, IEnumerable? exclude) { return include.Any(includePattern => FileSystemName.MatchesSimpleExpression(includePattern, path)) - && (exclude is null || !exclude.Any(excludePattern => FileSystemName.MatchesSimpleExpression(excludePattern, path))); + && (exclude is null || (!exclude.Any(excludePattern => FileSystemName.MatchesSimpleExpression(excludePattern, path)) + && !path.ToLinuxPath().Split('/', StringSplitOptions.RemoveEmptyEntries) + .SkipLast(1) + .Any(x => exclude.Any(excludePattern => FileSystemName.MatchesSimpleExpression(excludePattern, x))))); } } \ No newline at end of file diff --git a/tests/OneWare.Shared.UnitTests/OneWare.Shared.UnitTests.csproj b/tests/OneWare.Shared.UnitTests/OneWare.Shared.UnitTests.csproj new file mode 100644 index 00000000..7f61d8b2 --- /dev/null +++ b/tests/OneWare.Shared.UnitTests/OneWare.Shared.UnitTests.csproj @@ -0,0 +1,19 @@ + + + + + + net7.0 + Library + False + True + False + True + enable + + + + + + + diff --git a/tests/OneWare.Shared.UnitTests/ProjectHelperTests.cs b/tests/OneWare.Shared.UnitTests/ProjectHelperTests.cs new file mode 100644 index 00000000..a4a00c0e --- /dev/null +++ b/tests/OneWare.Shared.UnitTests/ProjectHelperTests.cs @@ -0,0 +1,18 @@ +using OneWare.Shared.Helpers; +using Xunit; + +namespace OneWare.Shared.UnitTests; + +public class ProjectHelperTests +{ + [Fact] + public void MathWildCardTests() + { + var include = new[] {"**"}; + var exclude = new[] {".git"}; + + Assert.False(ProjectHelper.MatchWildCards(".git/FETCH_HEAD", include, exclude)); + Assert.True(ProjectHelper.MatchWildCards("test.vhd", include, exclude)); + Assert.True(ProjectHelper.MatchWildCards("nice/test.vhd", include, exclude)); + } +} \ No newline at end of file