public IEnumerable <string> ConvertToUrl(GitCommitEvent commitEvent) { if (string.IsNullOrWhiteSpace(commitEvent?.Repository?.HtmlUrl)) { _logger.LogInformation("commit {commitId} event doesn't have html url", commitEvent?.Repository?.Id); } var pngObjects = commitEvent?.Commits.SelectMany(c => c.Added ?.Where(s => s.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) .Select(e => $"{commitEvent.Repository.HtmlUrl}/blob/{c.Id}/{e}")) .ToList(); if (pngObjects is null) { _logger.LogInformation("PngObjects object is null"); return(ImmutableArray <string> .Empty); } if (pngObjects.Any() is false) { _logger.LogInformation("Any Commits doesn't have any png"); return(ImmutableArray <string> .Empty); } return(pngObjects.AsEnumerable()); }
private static IEnumerable <PngImage> ExtractPngImageFilePaths(ILogger log, GitCommitEvent gitCommitEvents) { foreach (var commit in gitCommitEvents.Commits) { foreach (var added in commit.Added) { if (added.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) { var pngFilePath = $"{gitCommitEvents.Repository.Url}/raw/master/{added}"; log.LogInformation($"Extracted PNG file path: {pngFilePath}"); yield return(new PngImage { Name = added, Url = pngFilePath }); } } } }