mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 21:00:40 +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)
|
- [Introduction](#introduction)
|
||||||
- [Configuration Options](#configuration-options)
|
- [Configuration Options](#configuration-options)
|
||||||
- [Managing Mail Notifications](#managing-mail-notifications)
|
- [Managing Mail Notifications](#managing-mail-notifications)
|
||||||
- [Usage Types](#usage-types)
|
- [Automation and Usage](#usage-types)
|
||||||
- [Local Repo (CLI)](#working-from-a-local-repo-cli)
|
- [Local Repo (CLI)](#working-from-a-local-repo-cli)
|
||||||
- [Online Usage](#online-usage)
|
- [Online Usage](#online-usage)
|
||||||
- [GitHub App](#working-with-github-app)
|
- [GitHub App](#working-with-github-app)
|
||||||
|
@ -47,6 +47,19 @@ def emphasize_header(text: str) -> str:
|
|||||||
get_logger().exception(f"Failed to emphasize header: {e}")
|
get_logger().exception(f"Failed to emphasize header: {e}")
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
def convert_to_markdown(output_data: dict, gfm_supported: bool = True) -> str:
|
||||||
"""
|
"""
|
||||||
Convert a dictionary of data into markdown format.
|
Convert a dictionary of data into markdown format.
|
||||||
@ -89,12 +102,16 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str:
|
|||||||
elif 'possible issues' in key_nice.lower():
|
elif 'possible issues' in key_nice.lower():
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
issues = value.split('\n- ')
|
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)
|
number_of_issues = len(issues)
|
||||||
if number_of_issues > 1:
|
if number_of_issues > 1:
|
||||||
markdown_text += f"<tr><td rowspan={number_of_issues}> {emoji} <strong>{key_nice}</strong></td>\n"
|
markdown_text += f"<tr><td rowspan={number_of_issues}> {emoji} <strong>{key_nice}</strong></td>\n"
|
||||||
for i, issue in enumerate(issues):
|
for i, issue in enumerate(issues):
|
||||||
issue = issue.strip('-').strip()
|
if not issue:
|
||||||
issue = emphasize_header(issue.strip())
|
continue
|
||||||
|
issue = emphasize_header(issue)
|
||||||
if i == 0:
|
if i == 0:
|
||||||
markdown_text += f"<td>\n\n{issue}</td></tr>\n"
|
markdown_text += f"<td>\n\n{issue}</td></tr>\n"
|
||||||
else:
|
else:
|
||||||
|
@ -138,15 +138,8 @@ Description:
|
|||||||
======
|
======
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{%- if commit_messages_str %}
|
|
||||||
|
|
||||||
Commit messages:
|
|
||||||
======
|
|
||||||
{{commit_messages_str}}
|
|
||||||
======
|
|
||||||
{%- endif %}
|
|
||||||
|
|
||||||
{%- if question_str %}
|
{%- if question_str %}
|
||||||
|
|
||||||
=====
|
=====
|
||||||
Here are questions to better understand the PR. Use the answers to provide better feedback.
|
Here are questions to better understand the PR. Use the answers to provide better feedback.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user