@@ -148133,7 +148133,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
148133
148133
exports.robot = void 0;
148134
148134
const chat_js_1 = __nccwpck_require__(85365);
148135
148135
const OPENAI_API_KEY = 'OPENAI_API_KEY';
148136
- const MAX_PATCH_COUNT = 4000;
148136
+ const MAX_PATCH_COUNT = process.env.MAX_PATCH_LENGTH
148137
+ ? +process.env.MAX_PATCH_LENGTH
148138
+ : Infinity;
148137
148139
const robot = (app) => {
148138
148140
const loadChat = async (context) => {
148139
148141
if (process.env.OPENAI_API_KEY) {
@@ -148196,9 +148198,12 @@ const robot = (app) => {
148196
148198
base: commits[commits.length - 2].sha,
148197
148199
head: commits[commits.length - 1].sha,
148198
148200
});
148199
- const ignoreList = (process.env.IGNORE || process.env.ignore || '').split('\n').filter(v => v !== '');
148201
+ const ignoreList = (process.env.IGNORE || process.env.ignore || '')
148202
+ .split('\n')
148203
+ .filter((v) => v !== '');
148200
148204
const filesNames = files?.map((file) => file.filename) || [];
148201
- changedFiles = changedFiles?.filter((file) => filesNames.includes(file.filename) && !ignoreList.includes(file.filename));
148205
+ changedFiles = changedFiles?.filter((file) => filesNames.includes(file.filename) &&
148206
+ !ignoreList.includes(file.filename));
148202
148207
}
148203
148208
if (!changedFiles?.length) {
148204
148209
console.log('no target label attached');
@@ -148215,17 +148220,22 @@ const robot = (app) => {
148215
148220
console.log(`${file.filename} skipped caused by its diff is too large`);
148216
148221
continue;
148217
148222
}
148218
- const res = await chat?.codeReview(patch);
148219
- if (!!res) {
148220
- await context.octokit.pulls.createReviewComment({
148221
- repo: repo.repo,
148222
- owner: repo.owner,
148223
- pull_number: context.pullRequest().pull_number,
148224
- commit_id: commits[commits.length - 1].sha,
148225
- path: file.filename,
148226
- body: res,
148227
- position: patch.split('\n').length - 1,
148228
- });
148223
+ try {
148224
+ const res = await chat?.codeReview(patch);
148225
+ if (!!res) {
148226
+ await context.octokit.pulls.createReviewComment({
148227
+ repo: repo.repo,
148228
+ owner: repo.owner,
148229
+ pull_number: context.pullRequest().pull_number,
148230
+ commit_id: commits[commits.length - 1].sha,
148231
+ path: file.filename,
148232
+ body: res,
148233
+ position: patch.split('\n').length - 1,
148234
+ });
148235
+ }
148236
+ }
148237
+ catch (e) {
148238
+ console.error(`review ${file.filename} failed`, e);
148229
148239
}
148230
148240
}
148231
148241
console.timeEnd('gpt cost');
0 commit comments