Skip to content

Commit 9c4a3d8

Browse files
authored
Ignore files from outside the repository (#977)
1 parent ed9d010 commit 9c4a3d8

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/Cake.Issues.Tap.Tests/LogFileFormat/StylelintLogFileFormatTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,5 +216,18 @@ public void Should_Read_Issue_Correct_When_Absolute_Linux_Path(string repository
216216
.OfRule("block-no-empty")
217217
.Create());
218218
}
219+
220+
[Fact]
221+
public void Should_Ignore_Issues_From_Outside_Repository()
222+
{
223+
// Given
224+
var fixture = new TapIssuesProviderFixture<StylelintLogFileFormat>("absolute-windows-path.tap", @"c:\foo");
225+
226+
// When
227+
var issues = fixture.ReadIssues().ToList();
228+
229+
// Then
230+
issues.Count.ShouldBe(0);
231+
}
219232
}
220233
}

src/Cake.Issues.Tap/BaseTapLogFileFormat.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ protected static (bool Valid, string FilePath) ValidateFilePath(string filePath,
2121
filePath.NotNullOrWhiteSpace();
2222
repositorySettings.NotNull();
2323

24-
// Make path relative to repository root.
2524
if (!new FilePath(filePath).IsRelative)
2625
{
26+
// Ignore files from outside the repository.
27+
if (!filePath.IsInRepository(repositorySettings))
28+
{
29+
return (false, string.Empty);
30+
}
31+
32+
// Make path relative to repository root.
2733
filePath = filePath.NormalizePath().MakeFilePathRelativeToRepositoryRoot(repositorySettings);
2834
}
2935

src/Cake.Issues.Tap/LogFileFormat/StylelintLogFileFormat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override IEnumerable<IIssue> ReadIssues(
4040
// Read affected file from the result.
4141
if (!TryGetFile(tapResult, repositorySettings, out var fileName))
4242
{
43-
this.Log.Information("Skip element since file path could not be parsed");
43+
this.Log.Warning("Skip result {0} since file path could not be parsed", tapResult.TestPointID);
4444
continue;
4545
}
4646

0 commit comments

Comments
 (0)