mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 04:10:49 +08:00
Merge pull request #735 from Codium-ai/tr/fixes3
Add unique_strings function and remove duplicate issues in utils.py
This commit is contained in:
2
Usage.md
2
Usage.md
@ -4,7 +4,7 @@
|
||||
- [Introduction](#introduction)
|
||||
- [Configuration Options](#configuration-options)
|
||||
- [Managing Mail Notifications](#managing-mail-notifications)
|
||||
- [Usage Types](#usage-types)
|
||||
- [Automation and Usage](#usage-types)
|
||||
- [Local Repo (CLI)](#working-from-a-local-repo-cli)
|
||||
- [Online Usage](#online-usage)
|
||||
- [GitHub App](#working-with-github-app)
|
||||
|
@ -47,7 +47,20 @@ def emphasize_header(text: str) -> str:
|
||||
get_logger().exception(f"Failed to emphasize header: {e}")
|
||||
return text
|
||||
|
||||
def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str:
|
||||
|
||||
def unique_strings(input_list: List[str]) -> List[str]:
|
||||
if not input_list or not isinstance(input_list, list):
|
||||
return input_list
|
||||
seen = set()
|
||||
unique_list = []
|
||||
for item in input_list:
|
||||
if item not in seen:
|
||||
unique_list.append(item)
|
||||
seen.add(item)
|
||||
return unique_list
|
||||
|
||||
|
||||
def convert_to_markdown(output_data: dict, gfm_supported: bool = True) -> str:
|
||||
"""
|
||||
Convert a dictionary of data into markdown format.
|
||||
Args:
|
||||
@ -89,12 +102,16 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str:
|
||||
elif 'possible issues' in key_nice.lower():
|
||||
value = value.strip()
|
||||
issues = value.split('\n- ')
|
||||
for i, _ in enumerate(issues):
|
||||
issues[i] = issues[i].strip().strip('-').strip()
|
||||
issues = unique_strings(issues) # remove duplicates
|
||||
number_of_issues = len(issues)
|
||||
if number_of_issues > 1:
|
||||
markdown_text += f"<tr><td rowspan={number_of_issues}> {emoji} <strong>{key_nice}</strong></td>\n"
|
||||
for i, issue in enumerate(issues):
|
||||
issue = issue.strip('-').strip()
|
||||
issue = emphasize_header(issue.strip())
|
||||
if not issue:
|
||||
continue
|
||||
issue = emphasize_header(issue)
|
||||
if i == 0:
|
||||
markdown_text += f"<td>\n\n{issue}</td></tr>\n"
|
||||
else:
|
||||
|
@ -138,15 +138,8 @@ Description:
|
||||
======
|
||||
{%- endif %}
|
||||
|
||||
{%- if commit_messages_str %}
|
||||
|
||||
Commit messages:
|
||||
======
|
||||
{{commit_messages_str}}
|
||||
======
|
||||
{%- endif %}
|
||||
|
||||
{%- if question_str %}
|
||||
|
||||
=====
|
||||
Here are questions to better understand the PR. Use the answers to provide better feedback.
|
||||
|
||||
|
Reference in New Issue
Block a user