@@ -148211,6 +148211,7 @@ const robot = (app) => {
148211148211 return 'no change';
148212148212 }
148213148213 console.time('gpt cost');
148214+ const ress = [];
148214148215 for (let i = 0; i < changedFiles.length; i++) {
148215148216 const file = changedFiles[i];
148216148217 const patch = file.patch || '';
@@ -148224,11 +148225,7 @@ const robot = (app) => {
148224148225 try {
148225148226 const res = await chat?.codeReview(patch);
148226148227 if (!!res) {
148227- await context.octokit.pulls.createReviewComment({
148228- repo: repo.repo,
148229- owner: repo.owner,
148230- pull_number: context.pullRequest().pull_number,
148231- commit_id: commits[commits.length - 1].sha,
148228+ ress.push({
148232148229 path: file.filename,
148233148230 body: res,
148234148231 position: patch.split('\n').length - 1,
@@ -148239,6 +148236,20 @@ const robot = (app) => {
148239148236 console.error(`review ${file.filename} failed`, e);
148240148237 }
148241148238 }
148239+ try {
148240+ await context.octokit.pulls.createReview({
148241+ repo: repo.repo,
148242+ owner: repo.owner,
148243+ pull_number: context.pullRequest().pull_number,
148244+ body: "Code review by ChatGPT",
148245+ event: 'COMMENT',
148246+ commit_id: commits[commits.length - 1].sha,
148247+ comments: ress,
148248+ });
148249+ }
148250+ catch (e) {
148251+ console.error(`Failed to create review`, e);
148252+ }
148242148253 console.timeEnd('gpt cost');
148243148254 console.info('successfully reviewed', context.payload.pull_request.html_url);
148244148255 return 'success';
0 commit comments