Skip to content

Commit

Permalink
include comment signature in PR review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan Stanga committed Nov 22, 2024
1 parent 9005c5f commit b5a3d8a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,7 @@ function generateCommentThreads(
export function isOwnComment(comment: string): boolean {
return comment.includes(COMMENT_SIGNATURE);
}

export function buildComment(comment: string): string {
return comment + "\n\n" + COMMENT_SIGNATURE;
}
6 changes: 3 additions & 3 deletions src/pull_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { FileDiff, parseFileDiff } from "./diff";
import { Octokit } from "@octokit/action";
import { Context } from "@actions/github/lib/context";
import { listPullRequestCommentThreads } from "./comments";
import { buildComment, listPullRequestCommentThreads } from "./comments";

export async function handlePullRequest() {
const context = await loadContext();
Expand Down Expand Up @@ -233,7 +233,7 @@ async function submitReview(
pull_number: pull_request.number,
commit_id: pull_request.headSha,
path: file,
body: content,
body: buildComment(content),
line,
});
};
Expand Down Expand Up @@ -267,7 +267,7 @@ async function submitReview(
try {
let commentsData = lineComments.map((c) => ({
path: c.file,
body: c.content,
body: buildComment(c.content),
line: c.end_line,
side: "RIGHT",
start_line:
Expand Down
9 changes: 7 additions & 2 deletions src/pull_request_comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { info, warning } from "@actions/core";
import { loadContext } from "./context";
import config from "./config";
import { initOctokit } from "./octokit";
import { getCommentThread, isOwnComment, isThreadRelevant } from "./comments";
import {
buildComment,
getCommentThread,
isOwnComment,
isThreadRelevant,
} from "./comments";
import { parseFileDiff } from "./diff";
import { runReviewCommentPrompt } from "./prompts";

Expand Down Expand Up @@ -86,7 +91,7 @@ export async function handlePullRequestComment() {
pull_number: pull_request.number,
commit_id: pull_request.head.sha,
path: commentThread.file,
body: response.response_comment,
body: buildComment(response.response_comment),
in_reply_to: commentThread.comments[0].id,
});
}

0 comments on commit b5a3d8a

Please sign in to comment.