From 4d6906e5b47263b0a98ec1ee4e9b6eba2fafa836 Mon Sep 17 00:00:00 2001 From: KoCoder Date: Sat, 28 Feb 2026 11:10:31 +0100 Subject: [PATCH] CI: Issue Change Requests --- scripts/gemini_review/main.go | 19 +++++++++++-------- scripts/wordcount/main.go | 6 +++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/scripts/gemini_review/main.go b/scripts/gemini_review/main.go index dbe5d67..4399ea3 100644 --- a/scripts/gemini_review/main.go +++ b/scripts/gemini_review/main.go @@ -86,14 +86,15 @@ func main() { } if len(reviews) > 0 { - commentBody := "### 🤖 Gemini Writing Review\n\n" + strings.Join(reviews, "\n\n---\n\n") - _, _, err = client.CreateIssueComment(owner, repo, prNumber, gitea.CreateIssueCommentOption{ - Body: commentBody, + reviewBody := "### 🤖 Gemini Writing Review\n\n" + strings.Join(reviews, "\n\n---\n\n") + _, _, err = client.CreatePullReview(owner, repo, prNumber, gitea.CreatePullReviewOptions{ + State: gitea.ReviewStateRequestChanges, + Body: reviewBody, }) if err != nil { - log.Fatalf("Failed to post PR comment: %v", err) + log.Fatalf("Failed to create PR review: %v", err) } - fmt.Println("Successfully posted review comments.") + fmt.Println("Successfully created PR change request review.") } else { fmt.Println("No Markdown files to review or no suggestions found.") } @@ -116,11 +117,13 @@ func readFile(path string) (string, error) { func getGeminiReview(ctx context.Context, model *genai.GenerativeModel, content string) (string, error) { prompt := fmt.Sprintf(` Review the following Markdown content for spelling errors, grammar mistakes, and style improvements. +This review will be posted as a "Request Changes" on a Pull Request, so please be specific and actionable. Provide your feedback as a list of bullet points. For each point: 1. Identify the issue. -2. Provide the original text. -3. Suggest an alternative or fix. -4. Check the content on completeness and correctness. +2. Provide the original text snippet. +3. Suggest a clear alternative or fix. +4. Briefly explain why the change is necessary if not obvious. +5. Check the content for completeness and technical correctness. Content: %s diff --git a/scripts/wordcount/main.go b/scripts/wordcount/main.go index f97e6e1..851e3a1 100644 --- a/scripts/wordcount/main.go +++ b/scripts/wordcount/main.go @@ -17,8 +17,8 @@ func main() { repoFullName := os.Getenv("GITHUB_REPOSITORY") prNumberStr := os.Getenv("PR_NUMBER") - if token == "" || prNumberStr == "" { - log.Fatal("Missing required environment variables: GEMINI_API_KEY, GITEA_TOKEN, GITHUB_REPOSITORY, PR_NUMBER") + if token == "" || repoFullName == "" || prNumberStr == "" { + log.Fatal("Missing required environment variables: GITEA_TOKEN, GITHUB_REPOSITORY, PR_NUMBER") } if baseURL == "" { @@ -65,7 +65,7 @@ func main() { } if len(counts) > 0 { - commentBody := "### 🤖 Gemini Writing Review\n\n" + strings.Join(counts, "\n\n---\n\n") + commentBody := "### 🤖 Word Count Report\n\n" + strings.Join(counts, "\n\n---\n\n") _, _, err = client.CreateIssueComment(owner, repo, prNumber, gitea.CreateIssueCommentOption{ Body: commentBody, })