Skip to content

Commit

Permalink
(cake-contribGH-9) (cake-contribGH-10) Support issue message in Markd…
Browse files Browse the repository at this point in the history
…own and HTML format
  • Loading branch information
pascalberger committed Jul 27, 2019
1 parent 72287d6 commit 332ff23
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/Cake.Issues.GitRepository/GitRepositoryIssuesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected override IEnumerable<IIssue> InternalReadIssues(IssueCommentFormat for

if (this.IssueProviderSettings.CheckBinaryFilesTrackedByLfs)
{
result.AddRange(this.CheckForBinaryFilesNotTrackedByLfs());
result.AddRange(this.CheckForBinaryFilesNotTrackedByLfs(format));
}

return result;
Expand All @@ -67,8 +67,9 @@ protected override IEnumerable<IIssue> InternalReadIssues(IssueCommentFormat for
/// <summary>
/// Checks for binary files which are not tracked by LFS.
/// </summary>
/// <param name="format">Preferred format of the messages.</param>
/// <returns>List of issues for binary files which are not tracked by LFS.</returns>
private IEnumerable<IIssue> CheckForBinaryFilesNotTrackedByLfs()
private IEnumerable<IIssue> CheckForBinaryFilesNotTrackedByLfs(IssueCommentFormat format)
{
var allFiles = this.GetAllFilesFromRepository();
if (!allFiles.Any())
Expand Down Expand Up @@ -102,10 +103,23 @@ private IEnumerable<IIssue> CheckForBinaryFilesNotTrackedByLfs()
var result = new List<IIssue>();
foreach (var file in binaryFilesNotTrackedByLfs)
{
string message = null;
switch (format)
{
case IssueCommentFormat.Markdown:
message = $"The binary file `{file}` is not tracked by Git LFS";
break;
case IssueCommentFormat.Html:
message = $"The binary file <pre>{file}</pre> is not tracked by Git LFS";
break;
default:
message = $"The binary file \"{file}\" is not tracked by Git LFS";
break;
}

result.Add(
IssueBuilder
.NewIssue(
$"File '{file}' is a binary file but not tracked by LFS.", this)
.NewIssue(message, this)
.InFile(file)
.OfRule("BinaryFileNotTrackedByLfs")
.WithPriority(IssuePriority.Warning)
Expand Down

0 comments on commit 332ff23

Please sign in to comment.