mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-12-12 02:45:18 +00:00
Compare commits
5 commits
702215dc79
...
2000651fdb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2000651fdb | ||
|
|
7b9e8bff3b | ||
|
|
d80e229bdf | ||
|
|
1315fa651b | ||
|
|
ab808fd114 |
1 changed files with 64 additions and 41 deletions
|
|
@ -123,17 +123,42 @@ class PRCodeSuggestions:
|
|||
await self.publish_no_suggestions()
|
||||
return
|
||||
|
||||
# Filter data by suggestions_score_threshold
|
||||
score_threshold = max(1, int(get_settings().pr_code_suggestions.suggestions_score_threshold))
|
||||
data['code_suggestions'] = [
|
||||
d for d in data['code_suggestions']
|
||||
if int(d.get('score', 0)) >= score_threshold
|
||||
]
|
||||
|
||||
if not data['code_suggestions']:
|
||||
await self.publish_no_suggestions()
|
||||
return
|
||||
|
||||
# publish the suggestions
|
||||
if get_settings().config.publish_output:
|
||||
# If a temporary comment was published, remove it
|
||||
self.git_provider.remove_initial_comment()
|
||||
|
||||
# Publish table summarized suggestions
|
||||
if ((not get_settings().pr_code_suggestions.commitable_code_suggestions) and
|
||||
self.git_provider.is_supported("gfm_markdown")):
|
||||
# Logic for Inline Suggestions
|
||||
dual_threshold = int(get_settings().pr_code_suggestions.dual_publishing_score_threshold)
|
||||
if get_settings().pr_code_suggestions.commitable_code_suggestions or dual_threshold > 0:
|
||||
await self.push_inline_code_suggestions(data)
|
||||
|
||||
# Logic for Table Suggestions
|
||||
if self.git_provider.is_supported("gfm_markdown") and \
|
||||
(not get_settings().pr_code_suggestions.commitable_code_suggestions or dual_threshold > 0):
|
||||
|
||||
data_for_table = data
|
||||
# dual publishing mode
|
||||
if dual_threshold > 0:
|
||||
data_for_table = {'code_suggestions': []}
|
||||
for suggestion in data['code_suggestions']:
|
||||
if int(suggestion.get('score', 0)) >= dual_threshold:
|
||||
data_for_table['code_suggestions'].append(suggestion)
|
||||
|
||||
if data_for_table['code_suggestions']:
|
||||
# generate summarized suggestions
|
||||
pr_body = self.generate_summarized_suggestions(data)
|
||||
pr_body = self.generate_summarized_suggestions(data_for_table)
|
||||
get_logger().debug(f"PR output", artifact=pr_body)
|
||||
|
||||
# require self-review
|
||||
|
|
@ -168,14 +193,12 @@ class PRCodeSuggestions:
|
|||
self.git_provider.edit_comment(self.progress_response, body=pr_body)
|
||||
else:
|
||||
self.git_provider.publish_comment(pr_body)
|
||||
|
||||
# dual publishing mode
|
||||
if int(get_settings().pr_code_suggestions.dual_publishing_score_threshold) > 0:
|
||||
await self.dual_publishing(data)
|
||||
else:
|
||||
await self.push_inline_code_suggestions(data)
|
||||
if self.progress_response:
|
||||
self.git_provider.remove_comment(self.progress_response)
|
||||
else:
|
||||
if self.progress_response and not (get_settings().pr_code_suggestions.commitable_code_suggestions or dual_threshold > 0):
|
||||
self.git_provider.remove_comment(self.progress_response)
|
||||
else:
|
||||
get_logger().info('Code suggestions generated for PR, but not published since publish_output is False.')
|
||||
pr_body = self.generate_summarized_suggestions(data)
|
||||
|
|
|
|||
Loading…
Reference in a new issue