Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve exception message if multiple modified files with absolute paths are found #368

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Cake.Issues.PullRequests.Tests/IssueFiltererTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Cake.Issues.PullRequests.Tests
{
using System;
using System.Collections.Generic;
using System.Linq;
using Cake.Core.IO;
Expand Down Expand Up @@ -157,7 +158,9 @@ public void Should_Throw_If_Modified_Files_Contain_Absolute_Path()
new Dictionary<IIssue, IssueCommentInfo>()));

// Then
result.IsPullRequestIssuesException(@"Absolute file paths are not supported for modified files. Path: c:/FakeIssueProvider.cs");
result.IsPullRequestIssuesException(
@"Absolute file paths are not supported for modified files:" + Environment.NewLine +
@" c:/FakeIssueProvider.cs");
}

[Fact]
Expand Down
5 changes: 3 additions & 2 deletions src/Cake.Issues.PullRequests/IssueFilterer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ internal class IssueFilterer
/// <param name="modifiedFilePaths">List of modified files in the pull request.</param>
private static void ValidateModifiedFiles(IEnumerable<FilePath> modifiedFilePaths)
{
foreach (var filePath in modifiedFilePaths.Where(x => !x.IsRelative))
var absoluteFilePaths = modifiedFilePaths.Where(x => !x.IsRelative).ToList();
if (absoluteFilePaths.Any())
{
throw new PullRequestIssuesException(
$"Absolute file paths are not supported for modified files. Path: {filePath}");
$"Absolute file paths are not supported for modified files:{Environment.NewLine}{string.Join(Environment.NewLine, absoluteFilePaths.Select(x => " " + x))}");
}
}

Expand Down