Skip to content

Commit e5d8f01

Browse files
authored
The support for gitignore kills performance and there isn't a straightforward fix (#1589)
Will hopefully be re-enabled with #1587 closes #1584
1 parent c9231f3 commit e5d8f01

File tree

5 files changed

+38
-33
lines changed

5 files changed

+38
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ The tool command name was changed to just `csharpier`
4242
The assembly/exe names have changed to just `CSharpier`
4343

4444
### Support for ignoring files via a .gitignore [#631](https://github.com/belav/csharpier/issues/631)
45+
**Disabled for performance issues as of 1.0.1** see [#1588](https://github.com/belav/csharpier/issues/1588)
4546
CSharpier now works as follows when determining if a file should be ignored.
4647

4748
- .gitignore files are considered when determining if a file will be ignored. A .gitignore file at the same level as a given file will take priority over a .gitignore file above it in the directory tree.

Src/CSharpier.Cli/IgnoreFile.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System.Diagnostics.CodeAnalysis;
22
using System.IO.Abstractions;
3+
using CSharpier.Cli.Options;
4+
using CSharpier.Core;
35
using Ignore;
46

57
namespace CSharpier.Cli;
@@ -37,6 +39,7 @@ public bool IsIgnored(string filePath)
3739
CancellationToken cancellationToken
3840
)
3941
{
42+
DebugLogger.Log("Creating IgnoreFile for " + baseDirectoryPath);
4043
var ignoreFilePaths = FindIgnorePaths(baseDirectoryPath, fileSystem);
4144
if (ignoreFilePaths.Count == 0)
4245
{
@@ -110,11 +113,11 @@ private static List<string> FindIgnorePaths(string baseDirectoryPath, IFileSyste
110113
}
111114
}
112115

113-
var gitIgnoreFilePath = fileSystem.Path.Combine(directoryInfo.FullName, ".gitignore");
114-
if (fileSystem.File.Exists(gitIgnoreFilePath))
115-
{
116-
result.Add(gitIgnoreFilePath);
117-
}
116+
// var gitIgnoreFilePath = fileSystem.Path.Combine(directoryInfo.FullName, ".gitignore");
117+
// if (OptionsProvider.UseGitIgnore && fileSystem.File.Exists(gitIgnoreFilePath))
118+
// {
119+
// result.Add(gitIgnoreFilePath);
120+
// }
118121

119122
directoryInfo = directoryInfo.Parent;
120123
}

Src/CSharpier.Cli/Options/OptionsProvider.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,9 @@ CancellationToken cancellationToken
184184
directoryName,
185185
this.ignoreFilesByDirectory,
186186
(searchingDirectory) =>
187-
this.fileSystem.File.Exists(Path.Combine(searchingDirectory, ".gitignore"))
188-
|| this.fileSystem.File.Exists(
189-
Path.Combine(searchingDirectory, ".csharpierignore")
190-
),
187+
// this.fileSystem.File.Exists(Path.Combine(searchingDirectory, ".gitignore"))
188+
//||
189+
this.fileSystem.File.Exists(Path.Combine(searchingDirectory, ".csharpierignore")),
191190
(searchingDirectory) =>
192191
IgnoreFile.CreateAsync(searchingDirectory, this.fileSystem, cancellationToken)
193192
);

Src/CSharpier.Tests/CommandLineFormatterTests.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ public void Ignore_Reports_Errors()
628628
[TestCase("File.cs", "!File.cs", false)]
629629
[TestCase("", "File.cs", true)]
630630
[TestCase("!File.cs", "File.cs", true)]
631-
[TestCase("File.cs", "", true)]
631+
// [TestCase("File.cs", "", true)]
632632
public void CSharpier_Ignore_And_Git_Ignore_Root_Level(
633633
string gitIgnoreContents,
634634
string csharpierIgnoreContents,
@@ -651,7 +651,7 @@ bool isIgnored
651651
[TestCase("File.cs", "!File.cs", false)]
652652
[TestCase("", "File.cs", true)]
653653
[TestCase("!File.cs", "File.cs", true)]
654-
[TestCase("File.cs", "", true)]
654+
// [TestCase("File.cs", "", true)]
655655
public void CSharpier_Ignore_And_Git_Ignore_Sub_Level(
656656
string gitIgnoreContents,
657657
string csharpierIgnoreContents,
@@ -671,28 +671,28 @@ bool isIgnored
671671
.StartWith(isIgnored ? "Formatted 0 files in " : "Formatted 1 files in ");
672672
}
673673

674-
[TestCase("File.cs", "!File.cs", false)]
675-
[TestCase("", "File.cs", true)]
676-
[TestCase("!File.cs", "File.cs", true)]
677-
[TestCase("File.cs", "", true)]
678-
public void Two_Git_Ignores(
679-
string rootGitIgnoreContents,
680-
string subGitIgnoreContents,
681-
bool isIgnored
682-
)
683-
{
684-
var context = new TestContext();
685-
context.WhenAFileExists("Sub/File.cs", UnformattedClassContent);
686-
context.WhenAFileExists(".gitignore", rootGitIgnoreContents);
687-
context.WhenAFileExists("Sub/.gitignore", subGitIgnoreContents);
688-
689-
var result = Format(context);
690-
691-
result
692-
.OutputLines.FirstOrDefault()
693-
.Should()
694-
.StartWith(isIgnored ? "Formatted 0 files in " : "Formatted 1 files in ");
695-
}
674+
// [TestCase("File.cs", "!File.cs", false)]
675+
// [TestCase("", "File.cs", true)]
676+
// [TestCase("!File.cs", "File.cs", true)]
677+
// [TestCase("File.cs", "", true)]
678+
// public void Two_Git_Ignores(
679+
// string rootGitIgnoreContents,
680+
// string subGitIgnoreContents,
681+
// bool isIgnored
682+
// )
683+
// {
684+
// var context = new TestContext();
685+
// context.WhenAFileExists("Sub/File.cs", UnformattedClassContent);
686+
// context.WhenAFileExists(".gitignore", rootGitIgnoreContents);
687+
// context.WhenAFileExists("Sub/.gitignore", subGitIgnoreContents);
688+
//
689+
// var result = Format(context);
690+
//
691+
// result
692+
// .OutputLines.FirstOrDefault()
693+
// .Should()
694+
// .StartWith(isIgnored ? "Formatted 0 files in " : "Formatted 1 files in ");
695+
// }
696696

697697
[Test]
698698
public void Write_Stdout_Should_Only_Write_File()

docs/Ignore.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Uploads/
1717
```
1818

1919
### .gitignore
20+
**Disabled for performance issues as of 1.0.1** see [#1588](https://github.com/belav/csharpier/issues/1588)
21+
2022
CSharpier will read the contents of `.gitignore` files and use them in addition to a `.csharpierignore` file to determine if a file should be ignored.
2123

2224
If a directory tree contains a `.csharpierignore` file then patterns in that file will always take priority over any `.gitignore` file in the same tree.

0 commit comments

Comments
 (0)