mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 21:00:40 +08:00
table
This commit is contained in:
@ -204,6 +204,9 @@ def convert_to_markdown_v2(output_data: dict, gfm_supported: bool = True, increm
|
|||||||
# if not output_data or not output_data.get('review', {}):
|
# if not output_data or not output_data.get('review', {}):
|
||||||
# return ""
|
# return ""
|
||||||
|
|
||||||
|
if gfm_supported:
|
||||||
|
markdown_text += "<table>\n"
|
||||||
|
|
||||||
for key, value in output_data['review'].items():
|
for key, value in output_data['review'].items():
|
||||||
if value is None or value == '' or value == {} or value == []:
|
if value is None or value == '' or value == {} or value == []:
|
||||||
if key.lower() != 'can_be_split':
|
if key.lower() != 'can_be_split':
|
||||||
@ -216,43 +219,83 @@ def convert_to_markdown_v2(output_data: dict, gfm_supported: bool = True, increm
|
|||||||
blue_bars = '🔵' * value_int
|
blue_bars = '🔵' * value_int
|
||||||
white_bars = '⚪' * (5 - value_int)
|
white_bars = '⚪' * (5 - value_int)
|
||||||
value = f"{value.strip()} {blue_bars}{white_bars}"
|
value = f"{value.strip()} {blue_bars}{white_bars}"
|
||||||
|
if gfm_supported:
|
||||||
|
markdown_text += f"<tr><td>"
|
||||||
|
markdown_text += f"{emoji} <strong>{key_nice}</strong>: {value}"
|
||||||
|
markdown_text += f"</td></tr>\n"
|
||||||
|
else:
|
||||||
markdown_text += f"### {emoji} {key_nice}: {value}\n\n"
|
markdown_text += f"### {emoji} {key_nice}: {value}\n\n"
|
||||||
elif 'relevant tests' in key_nice.lower():
|
elif 'relevant tests' in key_nice.lower():
|
||||||
value = value.strip().lower()
|
value = value.strip().lower()
|
||||||
|
if gfm_supported:
|
||||||
|
markdown_text += f"<tr><td>"
|
||||||
|
if is_value_no(value):
|
||||||
|
markdown_text += f"{emoji} <strong>No relevant tests</strong>"
|
||||||
|
else:
|
||||||
|
markdown_text += f"{emoji} <strong>PR contains tests</strong>"
|
||||||
|
markdown_text += f"</td></tr>\n"
|
||||||
|
else:
|
||||||
|
if gfm_supported:
|
||||||
|
markdown_text += f"<tr><td>"
|
||||||
|
if is_value_no(value):
|
||||||
|
markdown_text += f"{emoji} <strong>No relevant tests</strong>"
|
||||||
|
else:
|
||||||
|
markdown_text += f"{emoji} <strong>PR contains tests</strong>"
|
||||||
|
else:
|
||||||
if is_value_no(value):
|
if is_value_no(value):
|
||||||
markdown_text += f'### {emoji} No relevant tests\n\n'
|
markdown_text += f'### {emoji} No relevant tests\n\n'
|
||||||
else:
|
else:
|
||||||
markdown_text += f"### PR contains tests\n\n"
|
markdown_text += f"### PR contains tests\n\n"
|
||||||
elif 'security concerns' in key_nice.lower():
|
elif 'security concerns' in key_nice.lower():
|
||||||
|
if gfm_supported:
|
||||||
|
markdown_text += f"<tr><td>"
|
||||||
|
if is_value_no(value):
|
||||||
|
markdown_text += f"{emoji} <strong>No security concerns identified</strong>"
|
||||||
|
else:
|
||||||
|
markdown_text += f"{emoji} <strong>Security concerns</strong>"
|
||||||
|
value = emphasize_header(value.strip())
|
||||||
|
markdown_text += f"{value}"
|
||||||
|
markdown_text += f"</td></tr>\n"
|
||||||
|
else:
|
||||||
if is_value_no(value):
|
if is_value_no(value):
|
||||||
markdown_text += f'### {emoji} No security concerns identified\n\n'
|
markdown_text += f'### {emoji} No security concerns identified\n\n'
|
||||||
else:
|
else:
|
||||||
markdown_text += f"### {emoji} Security concerns\n\n"
|
markdown_text += f"### {emoji} Security concerns\n\n"
|
||||||
value = emphasize_header(value.strip())
|
value = emphasize_header(value.strip())
|
||||||
markdown_text += f"{value}\n\n"
|
markdown_text += f"{value}\n\n"
|
||||||
elif 'can be split' in key_nice.lower():
|
elif 'can be split' in key_nice.lower() and gfm_supported:
|
||||||
|
markdown_text += f"<tr><td>"
|
||||||
markdown_text += process_can_be_split(emoji, value)
|
markdown_text += process_can_be_split(emoji, value)
|
||||||
|
markdown_text += f"</td></tr>\n"
|
||||||
elif 'key issues to review' in key_nice.lower():
|
elif 'key issues to review' in key_nice.lower():
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
issues = value.split('\n- ')
|
issues = value.split('\n- ')
|
||||||
for i, _ in enumerate(issues):
|
for i, _ in enumerate(issues):
|
||||||
issues[i] = issues[i].strip().strip('-').strip()
|
issues[i] = issues[i].strip().strip('-').strip()
|
||||||
issues = unique_strings(issues) # remove duplicates
|
issues = unique_strings(issues) # remove duplicates
|
||||||
|
if gfm_supported:
|
||||||
|
markdown_text += f"<tr><td>"
|
||||||
|
markdown_text += f"{emoji} <strong>{key_nice}</strong><br><br>\n\n"
|
||||||
|
else:
|
||||||
markdown_text += f"### {emoji} Key issues to review\n\n"
|
markdown_text += f"### {emoji} Key issues to review\n\n"
|
||||||
for i, issue in enumerate(issues):
|
for i, issue in enumerate(issues):
|
||||||
if not issue:
|
if not issue:
|
||||||
continue
|
continue
|
||||||
issue = emphasize_header(issue, only_markdown=True)
|
issue = emphasize_header(issue, only_markdown=True)
|
||||||
markdown_text += f"{issue}\n\n"
|
markdown_text += f"{issue}\n\n"
|
||||||
# else:
|
if gfm_supported:
|
||||||
# value = emphasize_header(value.strip('-').strip())
|
markdown_text += f"</td></tr>\n"
|
||||||
# # value = replace_code_tags(value)
|
else:
|
||||||
# # markdown_text += f"<tr><td> {emoji} <strong>{key_nice}</strong></td><td>\n{value}\n\n</td></tr>\n"
|
if gfm_supported:
|
||||||
# markdown_text += f"### {emoji} {key_nice}: {value}\n\n"
|
markdown_text += f"<tr><td>"
|
||||||
|
markdown_text += f"{emoji} <strong>{key_nice}</strong>: {value}"
|
||||||
|
markdown_text += f"</td></tr>\n"
|
||||||
else:
|
else:
|
||||||
# markdown_text += f"<tr><td> {emoji} <strong>{key_nice}</strong></td><td>\n{value}\n\n</td></tr>\n"
|
|
||||||
markdown_text += f"### {emoji} {key_nice}: {value}\n\n"
|
markdown_text += f"### {emoji} {key_nice}: {value}\n\n"
|
||||||
|
|
||||||
|
if gfm_supported:
|
||||||
|
markdown_text += "</table>\n"
|
||||||
|
|
||||||
if 'code_feedback' in output_data:
|
if 'code_feedback' in output_data:
|
||||||
if gfm_supported:
|
if gfm_supported:
|
||||||
markdown_text += f"\n\n"
|
markdown_text += f"\n\n"
|
||||||
@ -280,9 +323,10 @@ def process_can_be_split(emoji, value):
|
|||||||
if not value or isinstance(value, list) and len(value) == 1:
|
if not value or isinstance(value, list) and len(value) == 1:
|
||||||
value = "No"
|
value = "No"
|
||||||
# markdown_text += f"<tr><td> {emoji} <strong>{key_nice}</strong></td><td>\n\n{value}\n\n</td></tr>\n"
|
# markdown_text += f"<tr><td> {emoji} <strong>{key_nice}</strong></td><td>\n\n{value}\n\n</td></tr>\n"
|
||||||
markdown_text += f"### {emoji} No multiple PR themes\n\n"
|
# markdown_text += f"### {emoji} No multiple PR themes\n\n"
|
||||||
|
markdown_text += f"{emoji} <strong>No multiple PR themes</strong><\n\n"
|
||||||
else:
|
else:
|
||||||
markdown_text += f"### {emoji} {key_nice}\n\n"
|
markdown_text += f"{emoji} <strong>{key_nice}</strong><br><br>\n\n"
|
||||||
for i, split in enumerate(value):
|
for i, split in enumerate(value):
|
||||||
title = split.get('title', '')
|
title = split.get('title', '')
|
||||||
relevant_files = split.get('relevant_files', [])
|
relevant_files = split.get('relevant_files', [])
|
||||||
|
Reference in New Issue
Block a user