pranav8tripathi@gmail.com commited on
Commit
edf1d63
Β·
1 Parent(s): 9455009

enhanced comments

Browse files
Files changed (2) hide show
  1. app/github_service.py +11 -8
  2. app/github_webhook.py +12 -12
app/github_service.py CHANGED
@@ -32,14 +32,17 @@ async def post_file_review(owner: str, repo: str, pr_number: int, filename: str,
32
 
33
  review_body = f"### πŸ€– AI Review: `{filename}`\n\n"
34
 
35
- for c in ai_feedback:
36
- line = c.get("line", 0)
37
- severity = c.get("severity", "info").capitalize()
38
- comment = c.get("comment", "").strip()
39
- emoji_map = {"low": "🟒", "medium": "🟠", "high": "πŸ”΄", "info": "πŸ’‘"}
40
- emoji = emoji_map.get(c.get("severity", "").lower(), "πŸ’‘")
41
-
42
- review_body += f"{emoji} **{severity}** (Line {line}): {comment}\n\n"
 
 
 
43
 
44
  review_body += "_Posted by PRism AI Reviewer_ πŸ€–"
45
 
 
32
 
33
  review_body = f"### πŸ€– AI Review: `{filename}`\n\n"
34
 
35
+ if not ai_feedback:
36
+ review_body += "βœ… No critical issues found in this file.\n\n"
37
+ else:
38
+ for c in ai_feedback:
39
+ line = c.get("line", 0)
40
+ severity = c.get("severity", "info").capitalize()
41
+ comment = c.get("comment", "").strip()
42
+ emoji_map = {"low": "🟒", "medium": "🟠", "high": "πŸ”΄", "info": "πŸ’‘"}
43
+ emoji = emoji_map.get(c.get("severity", "").lower(), "πŸ’‘")
44
+
45
+ review_body += f"{emoji} **{severity}** (Line {line}): {comment}\n\n"
46
 
47
  review_body += "_Posted by PRism AI Reviewer_ πŸ€–"
48
 
app/github_webhook.py CHANGED
@@ -31,7 +31,7 @@ async def github_webhook(request: Request):
31
  event_type = request.headers.get("X-GitHub-Event", "")
32
  logger.info(f"πŸ“‹ Event Type: {event_type}")
33
 
34
- # Only process pull_request events
35
  if event_type != "pull_request":
36
  logger.info(f"⏭️ Ignoring {event_type} event (only processing pull_request events)")
37
  return {"message": f"Ignored {event_type} event"}
@@ -90,7 +90,8 @@ async def github_webhook(request: Request):
90
  files_with_patches = [f for f in files if f.get("patch") and should_review_file(f["filename"])]
91
 
92
  if files_with_patches:
93
- initial_msg = f"πŸ€– **PRism AI is reviewing your PR...**\n\nAnalyzing {len(files_with_patches)} file(s). Only critical issues will be reported."
 
94
  await post_pr_comment(owner, repo, pr_number, initial_msg)
95
  logger.info("πŸ“’ Posted initial status comment")
96
  else:
@@ -119,13 +120,10 @@ async def github_webhook(request: Request):
119
  ai_feedback = await analyze_code(f["filename"], f["patch"])
120
  logger.info(f" βœ… AI returned {len(ai_feedback)} comments")
121
 
122
- # Post review for this file immediately
123
- if ai_feedback:
124
- await post_file_review(owner, repo, pr_number, f["filename"], ai_feedback)
125
- total_comments += len(ai_feedback)
126
- logger.info(f" πŸ“€ Posted {len(ai_feedback)} comments for {f['filename']}")
127
- else:
128
- logger.info(f" βœ… No issues found in {f['filename']}")
129
  except Exception as file_error:
130
  logger.error(f" ❌ Error analyzing {f['filename']}: {str(file_error)}")
131
  # Post error comment for this file
@@ -137,11 +135,13 @@ async def github_webhook(request: Request):
137
 
138
  if files_analyzed > 0:
139
  summary_msg = f"βœ… **PRism AI Review Complete!**\n\n"
140
- summary_msg += f"πŸ“Š Analyzed {files_analyzed} file(s)\n"
141
  if total_comments == 0:
142
- summary_msg += "\nπŸŽ‰ No critical issues found! Code looks good."
143
  else:
144
- summary_msg += f"πŸ’¬ Found {total_comments} issue(s) - please review above."
 
 
145
 
146
  await post_pr_comment(owner, repo, pr_number, summary_msg)
147
  logger.info("βœ… Posted final summary")
 
31
  event_type = request.headers.get("X-GitHub-Event", "")
32
  logger.info(f"πŸ“‹ Event Type: {event_type}")
33
 
34
+ # Only process pull_request events- Ignore rest
35
  if event_type != "pull_request":
36
  logger.info(f"⏭️ Ignoring {event_type} event (only processing pull_request events)")
37
  return {"message": f"Ignored {event_type} event"}
 
90
  files_with_patches = [f for f in files if f.get("patch") and should_review_file(f["filename"])]
91
 
92
  if files_with_patches:
93
+ #hello
94
+ initial_msg = f"πŸ€– **PRism AI is reviewing your PR right now...**\n\nAnalyzing {len(files_with_patches)} file(s). Only critical issues will be reported."
95
  await post_pr_comment(owner, repo, pr_number, initial_msg)
96
  logger.info("πŸ“’ Posted initial status comment")
97
  else:
 
120
  ai_feedback = await analyze_code(f["filename"], f["patch"])
121
  logger.info(f" βœ… AI returned {len(ai_feedback)} comments")
122
 
123
+ # Post review for this file immediately (even if no issues)
124
+ await post_file_review(owner, repo, pr_number, f["filename"], ai_feedback)
125
+ total_comments += len(ai_feedback)
126
+ logger.info(f" πŸ“€ Posted review for {f['filename']} ({len(ai_feedback)} issues)")
 
 
 
127
  except Exception as file_error:
128
  logger.error(f" ❌ Error analyzing {f['filename']}: {str(file_error)}")
129
  # Post error comment for this file
 
135
 
136
  if files_analyzed > 0:
137
  summary_msg = f"βœ… **PRism AI Review Complete!**\n\n"
138
+ summary_msg += f"πŸ“Š Analyzed **{files_analyzed}** file(s)\n"
139
  if total_comments == 0:
140
+ summary_msg += f"πŸ’¬ Found **{total_comments}** issue(s) - please review above.\n\n"
141
  else:
142
+ summary_msg += f"πŸ’¬ Found **{total_comments}** issue(s) - please review above.\n\n"
143
+
144
+ summary_msg += "---\n_Posted by PRism AI Reviewer_ πŸ€–"
145
 
146
  await post_pr_comment(owner, repo, pr_number, summary_msg)
147
  logger.info("βœ… Posted final summary")