Skip to content

Commit

Permalink
Fixing some issues with editorconfig parsing with globs (#1221)
Browse files Browse the repository at this point in the history
* Pull in new way to parse globs, dotnet.glob did not support what editorconfig needs. Customized GlobMatcher to allow single brace sets like [*.{cs}] and treat them like [*.cs]

closes #1214

* Make these internal
  • Loading branch information
belav authored Apr 7, 2024
1 parent 548b320 commit 5013141
Show file tree
Hide file tree
Showing 7 changed files with 1,388 additions and 8 deletions.
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<PackageVersion Include="BenchmarkDotNet.Annotations" Version="0.13.11" />
<PackageVersion Include="CliWrap" Version="3.6.4" />
<PackageVersion Include="DiffEngine" Version="6.5.7" />
<PackageVersion Include="DotNet.Glob" Version="3.1.3" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.3.3" />
<PackageVersion Include="Ignore" Version="0.1.50" />
Expand Down
37 changes: 37 additions & 0 deletions Src/CSharpier.Cli.Tests/EditorConfig/SectionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace CSharpier.Cli.Tests.EditorConfig;

using CSharpier.Cli.EditorConfig;
using FluentAssertions;
using IniParser.Model;
using NUnit.Framework;

[TestFixture]
public class SectionTests
{
[Test]
public void Test1()
{
var path = "/test/test.cs";
var result = new Section(new SectionData("*.cs"), "/test").IsMatch(path);

result.Should().BeTrue();
}

[Test]
public void Test2()
{
var path = "/test/test.cs";
var result = new Section(new SectionData("*.{cs}"), "/test").IsMatch(path);

result.Should().BeTrue();
}

[Test]
public void Test3()
{
var path = "/test/test.cs";
var result = new Section(new SectionData("*.{csx,cs}"), "/test").IsMatch(path);

result.Should().BeTrue();
}
}
1 change: 0 additions & 1 deletion Src/CSharpier.Cli/CSharpier.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<PublicKey>002400000480000094000000060200000024000052534131000400000100010049d266ea1aeae09c0abfce28b8728314d4e4807126ee8bc56155a7ddc765997ed3522908b469ae133fc49ef0bfa957df36082c1c2e0ec8cdc05a4ca4dbd4e1bea6c17fc1008555e15af13a8fc871a04ffc38f5e60e6203bfaf01d16a2a283b90572ade79135801c1675bf38b7a5a60ec8353069796eb53a26ffdddc9ee1273be</PublicKey>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DotNet.Glob" />
<PackageReference Include="Ignore" />
<PackageReference Include="ini-parser-netstandard" />
<PackageReference Include="Microsoft.Extensions.Logging" />
Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ IgnoreFile ignoreFile
SectionsIncludingParentFiles = FindSections(o.FullName, fileSystem)
};
})
.OrderByDescending(o => o.DirectoryName?.Length)
.OrderByDescending(o => o.DirectoryName.Length)
.ToList();
}

Expand Down
Loading

0 comments on commit 5013141

Please sign in to comment.