From bfa08ae58ff27226168ef719b3878f12ae3e7bc8 Mon Sep 17 00:00:00 2001 From: "Brady Stroud [SSW]" Date: Mon, 10 Jun 2024 10:15:10 +0930 Subject: [PATCH] Add Log to debug (#53) WIP: 4c919f1 Ensure PRs are under 101 files changed --- .../Functions/Widget/UpdateLatestRules.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/SSW.Rules.AzFuncs/Functions/Widget/UpdateLatestRules.cs b/SSW.Rules.AzFuncs/Functions/Widget/UpdateLatestRules.cs index 9d0dfa1..b3285fd 100644 --- a/SSW.Rules.AzFuncs/Functions/Widget/UpdateLatestRules.cs +++ b/SSW.Rules.AzFuncs/Functions/Widget/UpdateLatestRules.cs @@ -36,6 +36,8 @@ public async Task Run( StartPage = 1 }; + _logger.LogInformation("Getting pull requests"); + var pullRequests = await gitHubClient.PullRequest.GetAllForRepository(repositoryOwner, repositoryName, request, apiOptions); @@ -45,17 +47,24 @@ await gitHubClient.PullRequest.GetAllForRepository(repositoryOwner, repositoryNa throw new Exception("No Pull Requests found"); } + _logger.LogInformation("Getting sync history hash"); var syncHistoryHash = await context.SyncHistory.GetAll(); var existingCommitHashes = new HashSet(syncHistoryHash.Select(sh => sh.CommitHash)); HttpClient httpClient = new HttpClient(); var newRules = new List(); var updatedCount = 0; + foreach (var pr in pullRequests) { + _logger.LogInformation($"Scanning PR {pr.Number}"); if (existingCommitHashes.Contains(pr.MergeCommitSha)) break; if (!pr.Merged) continue; - if (pr.ChangedFiles > 100) continue; // Skips big PRs as these will fail + if (pr.ChangedFiles > 100) // Skips big PRs as these will fail + { + _logger.LogInformation($"Skipping PR {pr.Number}"); + continue; + }; var files = await gitHubClient.PullRequest.Files(repositoryOwner, repositoryName, pr.Number); foreach (var file in files)