Skip to content

Commit 37c97d5

Browse files
committed
feat: review phase posts findings as GitHub PR comment
The reviewer's full output is now posted as a comment on the PR with a clear LGTM/blocked verdict. Previously the review ran silently with no visible output on the PR itself.
1 parent 0d5b6f5 commit 37c97d5

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

internal/evolution/git.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,12 @@ func (e *Engine) reviewPR(ctx context.Context, p iteragent.Provider, tools []ite
193193
a.Finish()
194194

195195
low := strings.ToLower(reviewOutput)
196-
if strings.Contains(low, "lgtm") || strings.Contains(low, "looks good") {
196+
passed := strings.Contains(low, "lgtm") || strings.Contains(low, "looks good")
197+
198+
// Always post the review output as a PR comment for visibility.
199+
e.postReviewComment(ctx, reviewOutput, passed)
200+
201+
if passed {
197202
e.logger.Info("PR self-review passed")
198203
return nil
199204
}
@@ -203,6 +208,31 @@ func (e *Engine) reviewPR(ctx context.Context, p iteragent.Provider, tools []ite
203208
return fmt.Errorf("review blocked merge: reviewer did not say LGTM")
204209
}
205210

211+
// postReviewComment posts the reviewer's output as a GitHub PR comment.
212+
func (e *Engine) postReviewComment(ctx context.Context, reviewOutput string, passed bool) {
213+
if e.prNumber == 0 {
214+
return
215+
}
216+
217+
verdict := "❌ Issues found — merge blocked."
218+
if passed {
219+
verdict = "✅ LGTM — auto-merging."
220+
}
221+
222+
body := fmt.Sprintf("## Self-Review\n\n%s\n\n---\n**Verdict:** %s\n\n*Reviewed by iterate-evolve[bot]*",
223+
reviewOutput, verdict)
224+
225+
// Use exec.Command to avoid shell injection via body content.
226+
cmd := exec.Command("gh", "pr", "comment", fmt.Sprintf("%d", e.prNumber),
227+
"--repo", e.repo, "--body", body)
228+
cmd.Dir = e.repoPath
229+
if out, err := cmd.CombinedOutput(); err != nil {
230+
e.logger.Warn("failed to post review comment", "err", err, "output", string(out))
231+
} else {
232+
e.logger.Info("posted review comment", "pr", e.prNumber)
233+
}
234+
}
235+
206236
func (e *Engine) mergePR(ctx context.Context) error {
207237
if e.prNumber == 0 {
208238
return fmt.Errorf("no PR to merge")

0 commit comments

Comments
 (0)