mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 21:00:40 +08:00
s1
This commit is contained in:
@ -317,20 +317,19 @@ class PRDescription:
|
|||||||
return pr_body
|
return pr_body
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pr_body += """\n| | Relevant Files """
|
pr_body = ""
|
||||||
pr_body += " " * 70
|
pr_body += "<table>"
|
||||||
pr_body += """|\n|-----------|-------------|\n"""
|
pr_body += """<thead><tr><th></th><th>Relevant Files</th></tr></thead>"""
|
||||||
|
pr_body += """<tbody>"""
|
||||||
for semantic_label in value.keys():
|
for semantic_label in value.keys():
|
||||||
s_label = semantic_label.strip("'").strip('"')
|
s_label = semantic_label.strip("'").strip('"')
|
||||||
if self.git_provider.is_supported("gfm_markdown"):
|
pr_body += f"""<tr><td><strong>{s_label}</strong></td>"""
|
||||||
# pr_body += f"<details> <summary>{semantic_label['label']}</summary>\n\n"
|
|
||||||
pr_body += f"| **{s_label}** | <details><summary>files:</summary><ul>"
|
|
||||||
|
|
||||||
list_tuples = value[semantic_label]
|
list_tuples = value[semantic_label]
|
||||||
|
pr_body += f"""<td><details><summary>{len(list_tuples)} files</summary><table>"""
|
||||||
for filename, file_change_description in list_tuples:
|
for filename, file_change_description in list_tuples:
|
||||||
filename = filename.replace("'", "`")
|
filename = filename.replace("'", "`")
|
||||||
filename_publish = filename.split("/")[-1]
|
filename_publish = filename.split("/")[-1]
|
||||||
filename_publish = f"**{filename_publish}**"
|
filename_publish = f"{filename_publish}"
|
||||||
diff_plus_minus = ""
|
diff_plus_minus = ""
|
||||||
diff_files = self.git_provider.diff_files
|
diff_files = self.git_provider.diff_files
|
||||||
for f in diff_files:
|
for f in diff_files:
|
||||||
@ -341,24 +340,72 @@ class PRDescription:
|
|||||||
break
|
break
|
||||||
|
|
||||||
# try to add line numbers link to code suggestions
|
# try to add line numbers link to code suggestions
|
||||||
|
link = ""
|
||||||
if hasattr(self.git_provider, 'get_line_link'):
|
if hasattr(self.git_provider, 'get_line_link'):
|
||||||
filename = filename.strip()
|
filename = filename.strip()
|
||||||
link = self.git_provider.get_line_link(filename, relevant_line_start=-1)
|
link = self.git_provider.get_line_link(filename, relevant_line_start=-1)
|
||||||
if link:
|
|
||||||
diff_plus_minus = f"[{diff_plus_minus}]({link})"
|
|
||||||
diff_plus_minus = f" <sup>{diff_plus_minus}</sup>"
|
|
||||||
|
|
||||||
if diff_plus_minus:
|
file_change_description = self._insert_br_after_x_chars(file_change_description)
|
||||||
filename_publish += diff_plus_minus
|
pr_body += f"""
|
||||||
if self.git_provider.is_supported("gfm_markdown"):
|
<tr>
|
||||||
pr_body += f"<details><summary>{filename_publish}</summary>"
|
<td>
|
||||||
file_change_description = self._insert_br_after_x_chars(file_change_description)
|
<details>
|
||||||
if diff_plus_minus:
|
<summary><strong>{filename_publish}</strong> <sup><a href="{link}"> {diff_plus_minus}</a></sup></summary>
|
||||||
pr_body += f"<ul>Changes summary:<br>**{file_change_description}**</ul></details>"
|
<ul>
|
||||||
else:
|
Changes summary:<br>
|
||||||
pr_body += f"<ul>Changes summary:<br>**{file_change_description}**</ul></details>"
|
<strong>{file_change_description}</strong>
|
||||||
if self.git_provider.is_supported("gfm_markdown"):
|
</ul>
|
||||||
pr_body += "</ul></details>|\n"
|
</details>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
"""
|
||||||
|
pr_body += """</table></details></td></tr>"""
|
||||||
|
pr_body += """</tr></tbody></table>"""
|
||||||
|
print(pr_body)
|
||||||
|
|
||||||
|
|
||||||
|
# pr_body += """\n| | Relevant Files """
|
||||||
|
# pr_body += " " * 70
|
||||||
|
# pr_body += """|\n|-----------|-------------|\n"""
|
||||||
|
# for semantic_label in value.keys():
|
||||||
|
# s_label = semantic_label.strip("'").strip('"')
|
||||||
|
# if self.git_provider.is_supported("gfm_markdown"):
|
||||||
|
# # pr_body += f"<details> <summary>{semantic_label['label']}</summary>\n\n"
|
||||||
|
# pr_body += f"| **{s_label}** | <details><summary>files:</summary><ul>"
|
||||||
|
#
|
||||||
|
# list_tuples = value[semantic_label]
|
||||||
|
# for filename, file_change_description in list_tuples:
|
||||||
|
# filename = filename.replace("'", "`")
|
||||||
|
# filename_publish = filename.split("/")[-1]
|
||||||
|
# filename_publish = f"**{filename_publish}**"
|
||||||
|
# diff_plus_minus = ""
|
||||||
|
# diff_files = self.git_provider.diff_files
|
||||||
|
# for f in diff_files:
|
||||||
|
# if f.filename.lower() == filename.lower():
|
||||||
|
# num_plus_lines = f.num_plus_lines
|
||||||
|
# num_minus_lines = f.num_minus_lines
|
||||||
|
# diff_plus_minus += f" ( +{num_plus_lines}/-{num_minus_lines} )"
|
||||||
|
# break
|
||||||
|
#
|
||||||
|
# # try to add line numbers link to code suggestions
|
||||||
|
# if hasattr(self.git_provider, 'get_line_link'):
|
||||||
|
# filename = filename.strip()
|
||||||
|
# link = self.git_provider.get_line_link(filename, relevant_line_start=-1)
|
||||||
|
# if link:
|
||||||
|
# diff_plus_minus = f"[{diff_plus_minus}]({link})"
|
||||||
|
# diff_plus_minus = f" <sup>{diff_plus_minus}</sup>"
|
||||||
|
#
|
||||||
|
# if diff_plus_minus:
|
||||||
|
# filename_publish += diff_plus_minus
|
||||||
|
# if self.git_provider.is_supported("gfm_markdown"):
|
||||||
|
# pr_body += f"<details><summary>{filename_publish}</summary>"
|
||||||
|
# file_change_description = self._insert_br_after_x_chars(file_change_description)
|
||||||
|
# if diff_plus_minus:
|
||||||
|
# pr_body += f"<ul>Changes summary:<br>**{file_change_description}**</ul></details>"
|
||||||
|
# else:
|
||||||
|
# pr_body += f"<ul>Changes summary:<br>**{file_change_description}**</ul></details>"
|
||||||
|
# if self.git_provider.is_supported("gfm_markdown"):
|
||||||
|
# pr_body += "</ul></details>|\n"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
get_logger().error(f"Error processing pr files to markdown {self.pr_id}: {e}")
|
get_logger().error(f"Error processing pr files to markdown {self.pr_id}: {e}")
|
||||||
pass
|
pass
|
||||||
|
Reference in New Issue
Block a user