Updated gitea comment retrieval

This commit is contained in:
2025-12-30 15:43:55 -05:00
parent 397c9aeb90
commit 002e809ef6
2 changed files with 11 additions and 13 deletions

View File

@@ -35,19 +35,15 @@ dotenv.config({path: '.env.local', override: true, quiet: true, debug: false});
return process.exit();
}
let existingComments = '';
let existingComments = 'Existing Comments:\n';
if(git && pr) {
const res = await fetch(`${git}/api/v1/repos/${owner}/${repo}/pulls/${pr}/reviews`, {
const reviews = await fetch(`${git}/api/v1/repos/${owner}/${repo}/pulls/${pr}/reviews`, {
headers: {'Authorization': `token ${auth}`}
});
if(res.ok) {
const reviews = await res.json();
const allComments = reviews.flatMap(r => r.comments || []);
if(allComments.length) {
existingComments = '\n\nExisting review comments (DO NOT repeat these):\n' +
allComments.map(c => `- ${c.path}:${c.line || c.position}: ${c.body}`).join('\n');
}
}
}).then(resp => resp.ok ? resp.json() : []);
const comments = await Promise.all(reviews.map(r => fetch(`${git}/api/v1/repos/${owner}/${repo}/pulls/${pr}/reviews/${r.id}/comments`, {
headers: {'Authorization': `token ${auth}`}
}).then(resp => resp.ok ? resp.json() : [])));
existingComments += comments.flatten().map(c => `${c.path}:${c.position}\n${c.body}`).join('\n\n');
}
let options = {ollama: {model, host}};