do not comment deleted files

This commit is contained in:
Daniel Prentis 2023-03-30 19:07:04 +02:00
parent cc0ff7a63b
commit a58f3e3c83
3 changed files with 1323 additions and 1321 deletions

5
dist/index.js vendored
View file

@ -1,4 +1,4 @@
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 3109:
@ -89,6 +89,7 @@ function analyzeCode(parsedDiff, prDetails) {
return __awaiter(this, void 0, void 0, function* () {
const comments = [];
for (const file of parsedDiff) {
if (file.to !== '/dev/null') {
for (const chunk of file.chunks) {
const prompt = createPrompt(file, chunk, prDetails);
const aiResponse = yield getAIResponse(prompt);
@ -100,6 +101,7 @@ function analyzeCode(parsedDiff, prDetails) {
}
}
}
}
return comments;
});
}
@ -18526,4 +18528,3 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
/******/
/******/ })()
;
//# sourceMappingURL=index.js.map

View file

@ -7,7 +7,7 @@
"license": "MIT",
"scripts": {
"build": "tsc",
"package": "ncc build --source-map --license licenses.txt",
"package": "ncc build",
"format": "prettier --write .",
"lint": "prettier --check ."
},

View file

@ -64,6 +64,7 @@ async function analyzeCode(
const comments: Array<{ body: string; path: string; line: number }> = [];
for (const file of parsedDiff) {
if (file.to !== '/dev/null') {
for (const chunk of file.chunks) {
const prompt = createPrompt(file, chunk, prDetails);
const aiResponse = await getAIResponse(prompt);
@ -75,6 +76,7 @@ async function analyzeCode(
}
}
}
}
return comments;
}
@ -86,8 +88,7 @@ function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string {
- Write the comment in GitHub markdown.
- Use the given description only for the overall context and only comment the code.
Review the following code diff in the file "${
file.to
Review the following code diff in the file "${file.to
}" and take the pull request title and description into account when writing the response.
Pull request title: ${prDetails.title}