Skip to content

Commit 5e253f8

Browse files
committed
Cleanup
1 parent 68f06ff commit 5e253f8

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/Cake.Issues.GitRepository.Tests/GitRepositoryIssuesProviderTests.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ public void Should_Filter_Out_Skip_Worktree_Files()
2121
var result = gitOutput
2222
.Where(x => !string.IsNullOrEmpty(x))
2323
.Where(x => !x.StartsWith("S ")) // Exclude skip-worktree files (sparse checkout)
24-
.Select(x => x.Length > 2 ? x.Substring(2) : x) // Remove status prefix (e.g., "H ")
24+
.Select(x => x.Length > 2 ? x[2..] : x) // Remove status prefix (e.g., "H ")
2525
.ToList();
2626

2727
// Then - Only non-skip-worktree files should remain
28-
result.ShouldNotBeNull();
2928
result.Count.ShouldBe(2);
3029
result.ShouldContain("file1.txt");
3130
result.ShouldContain("subdir/file3.txt");
@@ -43,12 +42,11 @@ public void Should_Handle_Empty_Output()
4342
var result = gitOutput
4443
.Where(x => !string.IsNullOrEmpty(x))
4544
.Where(x => !x.StartsWith("S "))
46-
.Select(x => x.Length > 2 ? x.Substring(2) : x)
45+
.Select(x => x.Length > 2 ? x[2..] : x)
4746
.ToList();
4847

4948
// Then - Result should be empty
50-
result.ShouldNotBeNull();
51-
result.Count.ShouldBe(0);
49+
result.ShouldNotBeNull().Count.ShouldBe(0);
5250
}
5351

5452
[Fact]
@@ -70,11 +68,10 @@ public void Should_Handle_Various_Git_Status_Codes()
7068
var result = gitOutput
7169
.Where(x => !string.IsNullOrEmpty(x))
7270
.Where(x => !x.StartsWith("S "))
73-
.Select(x => x.Length > 2 ? x.Substring(2) : x)
71+
.Select(x => x.Length > 2 ? x[2..] : x)
7472
.ToList();
7573

7674
// Then - Only skip-worktree files should be filtered out
77-
result.ShouldNotBeNull();
7875
result.Count.ShouldBe(5);
7976
result.ShouldContain("cached_file.txt");
8077
result.ShouldContain("modified_file.txt");
@@ -102,11 +99,10 @@ public void Should_Handle_Edge_Cases_In_Status_Parsing()
10299
var result = gitOutput
103100
.Where(x => !string.IsNullOrEmpty(x))
104101
.Where(x => !x.StartsWith("S "))
105-
.Select(x => x.Length > 2 ? x.Substring(2) : x)
102+
.Select(x => x.Length > 2 ? x[2..] : x)
106103
.ToList();
107104

108105
// Then
109-
result.ShouldNotBeNull();
110106
result.Count.ShouldBe(4);
111107
result.ShouldContain("normal_file.txt");
112108
result.ShouldContain("Sfile_without_space.txt"); // This wasn't filtered because no space after S

src/Cake.Issues.GitRepository/GitRepositoryIssuesProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ private List<string> GetAllFilesFromRepository()
192192
output)
193193
.Split('\0')
194194
.Where(x => !string.IsNullOrEmpty(x))
195-
.Where(x => !x.StartsWith("S ")) // Exclude skip-worktree files (sparse checkout)
196-
.Select(x => x.Length > 2 ? x.Substring(2) : x) // Remove status prefix (e.g., "H ")
195+
.Where(x => !x.StartsWith("S ", StringComparison.Ordinal)) // Exclude skip-worktree files (sparse checkout)
196+
.Select(x => x.Length > 2 ? x[2..] : x) // Remove status prefix (e.g., "H ")
197197
.ToList();
198198
this.Log.Verbose("Found {0} file(s)", result.Count);
199199

0 commit comments

Comments
 (0)