Skip to content

Commit fadd080

Browse files
authored
Merge branch 'main' into feature/1865-dont-chop-lambda
2 parents 8fc28da + 7426a5a commit fadd080

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

Src/CSharpier.Cli/DotIgnore/IgnoreRule.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,18 @@ public IgnoreRule(string pattern)
5454
{
5555
var rxOptions = RegexOptions.Compiled;
5656

57-
this.regex = new Regex(rxPattern, rxOptions);
57+
try
58+
{
59+
this.regex = new Regex(rxPattern, rxOptions);
60+
}
61+
catch (RegexParseException ex)
62+
when (ex.Message
63+
== "Invalid pattern '^Icon(?!/)[$' at offset 12. Unterminated [] set."
64+
)
65+
{
66+
// old macOS uses 'Icon\r' in folder names, which needs this in a .gitignore Icon[\r]\n
67+
// instead of dealing with that, just don't treat this line as regex
68+
}
5869
}
5970
}
6071

Src/CSharpier.Generators/CSharpier.Generators.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
66
<PackageScribanIncludeSource>true</PackageScribanIncludeSource>
77
<LangVersion>13</LangVersion>
8-
<NoWarn>SYSLIB0013;NU1903</NoWarn>
8+
<NoWarn>SYSLIB0013;NU1903;NU1902</NoWarn>
99
</PropertyGroup>
1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.CodeAnalysis.Common" />

Src/CSharpier.Tests/Cli/IgnoreFileTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,13 @@ public void Range()
595595
);
596596
}
597597

598+
[Test]
599+
public void MacOs()
600+
{
601+
// we can't actually test a folder name with \r in it, but this makes sure that we at least parse it
602+
this.GitBasedTest("# General\nBin\nIcon[\r]\nObj\n", ["Bin/file.txt", "Obj/file.txt"]);
603+
}
604+
598605
// TODO this passes because the ignorefile says the file is not ignored
599606
[Test]
600607
public void Thing()

0 commit comments

Comments
 (0)