mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-20 01:26:47 +00:00
Add support for pullrequest->labeled event
This commit is contained in:
parent
a9a064dfa1
commit
38e320dd5a
3 changed files with 1310 additions and 1308 deletions
3
dist/index.js
vendored
3
dist/index.js
vendored
|
@ -192,7 +192,8 @@ function main() {
|
||||||
const prDetails = yield getPRDetails();
|
const prDetails = yield getPRDetails();
|
||||||
let diff;
|
let diff;
|
||||||
const eventData = JSON.parse((0, fs_1.readFileSync)((_a = process.env.GITHUB_EVENT_PATH) !== null && _a !== void 0 ? _a : "", "utf8"));
|
const eventData = JSON.parse((0, fs_1.readFileSync)((_a = process.env.GITHUB_EVENT_PATH) !== null && _a !== void 0 ? _a : "", "utf8"));
|
||||||
if (eventData.action === "opened") {
|
let actionNames = ["opened", "labeled", "reopened"];
|
||||||
|
if (actionNames.includes(eventData.action)) {
|
||||||
diff = yield getDiff(prDetails.owner, prDetails.repo, prDetails.pull_number);
|
diff = yield getDiff(prDetails.owner, prDetails.repo, prDetails.pull_number);
|
||||||
}
|
}
|
||||||
else if (eventData.action === "synchronize") {
|
else if (eventData.action === "synchronize") {
|
||||||
|
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
15
src/main.ts
15
src/main.ts
|
@ -87,9 +87,8 @@ function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string {
|
||||||
- Use the given description only for the overall context and only comment the code.
|
- Use the given description only for the overall context and only comment the code.
|
||||||
- IMPORTANT: NEVER suggest adding comments to the code.
|
- IMPORTANT: NEVER suggest adding comments to the code.
|
||||||
|
|
||||||
Review the following code diff in the file "${
|
Review the following code diff in the file "${file.to
|
||||||
file.to
|
}" and take the pull request title and description into account when writing the response.
|
||||||
}" and take the pull request title and description into account when writing the response.
|
|
||||||
|
|
||||||
Pull request title: ${prDetails.title}
|
Pull request title: ${prDetails.title}
|
||||||
Pull request description:
|
Pull request description:
|
||||||
|
@ -103,9 +102,9 @@ Git diff to review:
|
||||||
\`\`\`diff
|
\`\`\`diff
|
||||||
${chunk.content}
|
${chunk.content}
|
||||||
${chunk.changes
|
${chunk.changes
|
||||||
// @ts-expect-error - ln and ln2 exists where needed
|
// @ts-expect-error - ln and ln2 exists where needed
|
||||||
.map((c) => `${c.ln ? c.ln : c.ln2} ${c.content}`)
|
.map((c) => `${c.ln ? c.ln : c.ln2} ${c.content}`)
|
||||||
.join("\n")}
|
.join("\n")}
|
||||||
\`\`\`
|
\`\`\`
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +187,9 @@ async function main() {
|
||||||
readFileSync(process.env.GITHUB_EVENT_PATH ?? "", "utf8")
|
readFileSync(process.env.GITHUB_EVENT_PATH ?? "", "utf8")
|
||||||
);
|
);
|
||||||
|
|
||||||
if (eventData.action === "opened") {
|
let actionNames: string[] = ["opened", "labeled", "reopened"]
|
||||||
|
|
||||||
|
if (actionNames.includes(eventData.action)) {
|
||||||
diff = await getDiff(
|
diff = await getDiff(
|
||||||
prDetails.owner,
|
prDetails.owner,
|
||||||
prDetails.repo,
|
prDetails.repo,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue