Skip to content

Commit

Permalink
WIP: 4c919f1 Ensure PRs are under 101 files changed
Browse files Browse the repository at this point in the history
  • Loading branch information
bradystroud committed Jun 10, 2024
1 parent 2dcee31 commit fffb835
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion SSW.Rules.AzFuncs/Functions/Widget/UpdateLatestRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public async Task<HttpResponseData> Run(
StartPage = 1
};

_logger.LogInformation("Getting pull requests");

var pullRequests =
await gitHubClient.PullRequest.GetAllForRepository(repositoryOwner, repositoryName, request,
apiOptions);
Expand All @@ -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<string>(syncHistoryHash.Select(sh => sh.CommitHash));
HttpClient httpClient = new HttpClient();
var newRules = new List<LatestRules>();
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)
Expand Down

0 comments on commit fffb835

Please sign in to comment.