generated from ztimson/template
Updated gitea comment retrieval
This commit is contained in:
@@ -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}};
|
||||
|
||||
Reference in New Issue
Block a user