From a41fbc2c0b6f8393ad67bde3def7baaf34dad752 Mon Sep 17 00:00:00 2001 From: goat Date: Mon, 13 Jan 2025 01:41:52 +0100 Subject: [PATCH] after-the-fact approvals --- Plogon/GitHubApi.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Plogon/GitHubApi.cs b/Plogon/GitHubApi.cs index a3750c5..28c705e 100644 --- a/Plogon/GitHubApi.cs +++ b/Plogon/GitHubApi.cs @@ -130,10 +130,16 @@ public async Task GetReviewer(int issueNumber) var firstApprovingReview = reviews.FirstOrDefault(r => r.State == PullRequestReviewState.Approved && PlogonSystemDefine.PacMembers.Contains(r.User.Login)); - if (firstApprovingReview == null) - throw new Exception($"No approving reviews on PR {issueNumber}"); - - return firstApprovingReview.User.Login; + if (firstApprovingReview != null) + return firstApprovingReview.User.Login; + + var comments = await this.ghClient.Issue.Comment.GetAllForIssue(repoOwner, repoName, issueNumber); + var firstApprovingComment = comments.FirstOrDefault(c => PlogonSystemDefine.PacMembers.Contains(c.User.Login) && + c.Body.Equals("bleatbot, approve", StringComparison.OrdinalIgnoreCase)); + if (firstApprovingComment != null) + return firstApprovingComment.User.Login; + + throw new Exception($"No approving reviews on PR {issueNumber}"); } ///