/// <summary> /// Checks for binary files which are not tracked by LFS. /// </summary> /// <returns>List of issues for binary files which are not tracked by LFS.</returns> private IEnumerable <IIssue> CheckForBinaryFilesNotTrackedByLfs() { if (!this.allFiles.Value.Any()) { return(new List <IIssue>()); } if (!this.binaryFiles.Value.Any()) { return(new List <IIssue>()); } var lfsTrackedFiles = this.GetLfsTrackedFilesFromRepository(); var binaryFilesNotTrackedByLfs = this.DetermineBinaryFilesNotTrackedWithLfs(this.binaryFiles.Value, lfsTrackedFiles); var result = new List <IIssue>(); foreach (var file in binaryFilesNotTrackedByLfs) { var ruleDescription = new BinaryFileNotTrackedByLfsRuleDescription(); result.Add( IssueBuilder .NewIssue($"The binary file \"{file}\" is not tracked by Git LFS", this) .WithMessageInHtmlFormat($"The binary file <code>{file}</code> is not tracked by Git LFS") .WithMessageInMarkdownFormat($"The binary file `{file}` is not tracked by Git LFS") .InFile(file) .OfRule(ruleDescription) .Create()); } return(result); }
/// <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(IssueCommentFormat format) { var allFiles = this.GetAllFilesFromRepository(); if (!allFiles.Any()) { return(new List <IIssue>()); } var textFiles = this.GetTextFilesFromRepository(); var binaryFiles = this.DetermineBinaryFiles(allFiles, textFiles); if (!binaryFiles.Any()) { return(new List <IIssue>()); } var lfsTrackedFiles = this.GetLfsTrackedFilesFromRepository(); var binaryFilesNotTrackedByLfs = this.DetermineBinaryFilesNotTrackedWithLfs(binaryFiles, lfsTrackedFiles); 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; } var ruleDescription = new BinaryFileNotTrackedByLfsRuleDescription(); result.Add( IssueBuilder .NewIssue(message, this) .InFile(file) .OfRule(ruleDescription) .Create()); } return(result); }