feat: implement comment persistence with unique HTML markers#50
feat: implement comment persistence with unique HTML markers#50
Conversation
…xisting PR comments, preventing duplicates.
🤖 Review Buddy - General Code Review
Oho @AnkanSaha! Maan gaye bhai, tune toh 're-inventing the wheel' ko naya matlab de diya. Ye Har comment ke liye tum poori list fetch kar rahe ho? Bhai, GitHub API tumhare baap ki jagah nahi hai ki unlimited requests bhejte rahoge. Ek hi PR mein 6 baar same comments fetch kar rahe ho—Review, Performance, Security, Quality, Best Practices, and Recommendations ke liye. Matlab efficiency ki toh tumne 'Gangs of Wasseypur' wali halat kar di hai. Aur ye Code Quality Score: 3/10 (Sirf isliye kyunki code chalta hai, par dimaag nahi lagaya gaya). Generated by Review Buddy | Tone: roast | Language: hinglish |
postOrUpdateComment with unique markers to update e…
⚡ Review Buddy - Performance Analysis
Arre bhai bhai bhai! Ye performance analysis dekh ke toh mere processor mein dard hone laga hai. Chalo, line-by-line tumhari 'kaari-gari' dekhte hain:
Actionable Recommendation: // Aise karo, thoda dimaag lagao
async function handlePullRequest(...) {
const allComments = await fetchPRComments(GITHUB_REPOSITORY, prNumber, GITHUB_TOKEN);
// Ek baar fetch karo aur filter kar lo markers ke basis pe
const commentMap = allComments.reduce((acc, c) => {
// Identify markers and map them
if (c.body.includes('<!-- Review Buddy Start -->')) acc.review = c;
// ... add others
return acc;
}, {});
// Ab seedha update ya post karo bina re-fetching ke
}Bhai, software engineer bano, API ka dushman nahi. Ye code dekh ke lagta hai tumne 'Cloud' ko sirf baarish ke liye samjha hai, computing ke liye nahi. Generated by Review Buddy | Tone: roast | Language: hinglish |
🔐 Review Buddy - Security Audit
Security ke naam pe toh tumne 'Welcome' movie ke Majnu Bhai wali painting bana di hai.
Generated by Review Buddy | Tone: roast | Language: hinglish |
📊 Review Buddy - Code Quality & Maintainability Analysis
🎯 Overall Benchmark: 45/100 (Poor)Quality? Woh kya hota hai? Lagta hai Ankan bhai ne SOLID principles ko 'SOLO' principles samajh liya hai - 'Main akela hi sab ganda code likhunga'.
Refactoring Suggestion: const STEPS = [
{ key: 'review', marker: '<!-- Review Buddy Start -->' },
{ key: 'performance', marker: '<!-- Review Buddy Performance -->' }
// ... etc
];
for (const step of STEPS) {
const content = getCleanedContent(step.key);
await postOrUpdateComment(repo, prNum, `${content}${footer}`, step.marker, token);
}Isse code 100 line se 20 line ka ho jayega. Par tumhe toh lines badhani hain, shayad LOC (Lines of Code) pe salary milti hai? Generated by Review Buddy | Tone: roast | Language: hinglish |
💡 Review Buddy - Best Practices & Alternative Suggestions
Bhai, coding standards ki toh tumne 'Lagaan' waali team bana di hai. Dekho kaise sudhaar sakte ho: 1. Guard ClausesCurrent Code: if (!body) return;Better Alternative: if (!body || body.trim() === '') {
logWarn('Empty body, skipping comment operation.');
return;
}Why: Sirf falsy check kafi nahi hai, empty strings bhi handle karo. 2. Logical Separation of ConcernsCurrent Code: 3. Template Literals vs String ConcatenationCurrent Code: const comment = `... ${cleanedReview} ${footer}`;Why: Template literals are fine, but try to avoid the massive blocks in 4. Search MethodCurrent Code: 5. Constants for MarkersCurrent Code: const MARKERS = {
REVIEW: '<!-- Review Buddy Start -->',
PERFORMANCE: '<!-- Review Buddy Performance -->',
// ...
};Why: Centralized control. Ek jagah change, har jagah change. Generated by Review Buddy | Tone: roast | Language: hinglish |
|
Summary
This PR introduces the
postOrUpdateCommentutility to avoid spamming Pull Requests with multiple comments. Instead of creating a new comment for every run, the bot now looks for a unique hidden HTML marker and updates the existing comment if found.Changes
postOrUpdateCommentfunction which fetches PR comments and checks for a specific marker string.postCommentwithpostOrUpdateCommentacross all analysis steps (Review, Performance, Security, Quality, Best Practices, and Recommendations).v5.18tov5.19.Verification