mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 21:00:40 +08:00
Add labeling files
This commit is contained in:
@ -46,8 +46,11 @@ keep_original_user_title=false
|
|||||||
use_bullet_points=true
|
use_bullet_points=true
|
||||||
extra_instructions = ""
|
extra_instructions = ""
|
||||||
enable_pr_type=true
|
enable_pr_type=true
|
||||||
|
enable_file_walkthrough=false
|
||||||
|
enable_semantic_files_types=true
|
||||||
final_update_message = true
|
final_update_message = true
|
||||||
|
|
||||||
|
|
||||||
# markers
|
# markers
|
||||||
use_description_markers=false
|
use_description_markers=false
|
||||||
include_generated_by_header=true
|
include_generated_by_header=true
|
||||||
|
@ -31,18 +31,31 @@ class PRType(str, Enum):
|
|||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if enable_file_walkthrough %}
|
||||||
class FileWalkthrough(BaseModel):
|
class FileWalkthrough(BaseModel):
|
||||||
filename: str = Field(description="the relevant file full path")
|
filename: str = Field(description="the relevant file full path")
|
||||||
changes_in_file: str = Field(description="minimal and concise description of the changes in the relevant file")
|
changes_in_file: str = Field(description="minimal and concise description of the changes in the relevant file")
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if enable_semantic_files_types %}
|
||||||
|
class SemanticLabelFiles(BaseModel):
|
||||||
|
label: PRType = Field(description="A label that represent a type of semantic code changes. Use the label value, not the name")
|
||||||
|
files: List[str] = Field(description="a list of files that are relevant to the label. A file may appear in multiple labels")
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
Class PRDescription(BaseModel):
|
Class PRDescription(BaseModel):
|
||||||
title: str = Field(description="an informative title for the PR, describing its main theme")
|
title: str = Field(description="an informative title for the PR, describing its main theme")
|
||||||
type: List[PRType] = Field(description="one or more types that describe the PR type. . Return the label value, not the name.")
|
type: List[PRType] = Field(description="one or more types that describe the PR type. Return the label value, not the name.")
|
||||||
description: str = Field(description="an informative and concise description of the PR. {%- if use_bullet_points %} Use bullet points.{% endif %}")
|
description: str = Field(description="an informative and concise description of the PR. {%- if use_bullet_points %} Use bullet points.{% endif %}")
|
||||||
{%- if enable_custom_labels %}
|
{%- if enable_custom_labels %}
|
||||||
labels: List[Label] = Field(min_items=0, description="custom labels that describe the PR. Return the label value, not the name.")
|
labels: List[Label] = Field(min_items=0, description="custom labels that describe the PR. Return the label value, not the name.")
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
{%- if enable_file_walkthrough %}
|
||||||
main_files_walkthrough: List[FileWalkthrough] = Field(max_items=10)
|
main_files_walkthrough: List[FileWalkthrough] = Field(max_items=10)
|
||||||
|
{%- endif %}
|
||||||
|
{%- if enable_semantic_files_types %}
|
||||||
|
pr_files_labels[SemanticLabelFiles]
|
||||||
|
{%- endif %}
|
||||||
=====
|
=====
|
||||||
|
|
||||||
|
|
||||||
@ -61,9 +74,21 @@ labels:
|
|||||||
{%- endif %}
|
{%- endif %}
|
||||||
description: |-
|
description: |-
|
||||||
...
|
...
|
||||||
|
{%- if enable_file_walkthrough %}
|
||||||
main_files_walkthrough:
|
main_files_walkthrough:
|
||||||
- ...
|
- ...
|
||||||
- ...
|
- ...
|
||||||
|
{%- endif %}
|
||||||
|
{%- if enable_semantic_files_types %}
|
||||||
|
pr_files_labels:
|
||||||
|
- label: ...
|
||||||
|
files:
|
||||||
|
- |
|
||||||
|
...
|
||||||
|
- |
|
||||||
|
...
|
||||||
|
...
|
||||||
|
{%- endif %}
|
||||||
```
|
```
|
||||||
|
|
||||||
Answer should be a valid YAML, and nothing else. Each YAML output MUST be after a newline, with proper indent, and block scalar indicator ('|-')
|
Answer should be a valid YAML, and nothing else. Each YAML output MUST be after a newline, with proper indent, and block scalar indicator ('|-')
|
||||||
|
@ -45,6 +45,8 @@ class PRDescription:
|
|||||||
"commit_messages_str": self.git_provider.get_commit_messages(),
|
"commit_messages_str": self.git_provider.get_commit_messages(),
|
||||||
"enable_custom_labels": get_settings().config.enable_custom_labels,
|
"enable_custom_labels": get_settings().config.enable_custom_labels,
|
||||||
"custom_labels_class": "", # will be filled if necessary in 'set_custom_labels' function
|
"custom_labels_class": "", # will be filled if necessary in 'set_custom_labels' function
|
||||||
|
"enable_file_walkthrough": get_settings().pr_description.enable_file_walkthrough,
|
||||||
|
"enable_semantic_files_types": get_settings().pr_description.enable_semantic_files_types,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.user_description = self.git_provider.get_user_description()
|
self.user_description = self.git_provider.get_user_description()
|
||||||
@ -257,7 +259,10 @@ class PRDescription:
|
|||||||
# except for the items containing the word 'walkthrough'
|
# except for the items containing the word 'walkthrough'
|
||||||
pr_body = ""
|
pr_body = ""
|
||||||
for idx, (key, value) in enumerate(self.data.items()):
|
for idx, (key, value) in enumerate(self.data.items()):
|
||||||
pr_body += f"## {key}:\n"
|
key_publish = key.rstrip(':').replace("_", " ").capitalize()
|
||||||
|
if key == 'pr_files_labels':
|
||||||
|
key_publish = 'PR Files Labels'
|
||||||
|
pr_body += f"## {key_publish}\n"
|
||||||
if 'walkthrough' in key.lower():
|
if 'walkthrough' in key.lower():
|
||||||
# for filename, description in value.items():
|
# for filename, description in value.items():
|
||||||
if self.git_provider.is_supported("gfm_markdown"):
|
if self.git_provider.is_supported("gfm_markdown"):
|
||||||
@ -268,6 +273,27 @@ class PRDescription:
|
|||||||
pr_body += f'- `{filename}`: {description}\n'
|
pr_body += f'- `{filename}`: {description}\n'
|
||||||
if self.git_provider.is_supported("gfm_markdown"):
|
if self.git_provider.is_supported("gfm_markdown"):
|
||||||
pr_body +="</details>\n"
|
pr_body +="</details>\n"
|
||||||
|
elif 'pr_files_labels' in key.lower():
|
||||||
|
pr_body += """\n| | Relevant Files """
|
||||||
|
for i in range(60):
|
||||||
|
pr_body += " "
|
||||||
|
pr_body += """|\n|-----------|-------------|\n"""
|
||||||
|
for semantic_label in value:
|
||||||
|
# for filename, description in value.items():
|
||||||
|
if self.git_provider.is_supported("gfm_markdown"):
|
||||||
|
# pr_body += f"<details> <summary>{semantic_label['label']}</summary>\n\n"
|
||||||
|
pr_body += f"| **{semantic_label['label']}** | <details><summary>files:</summary><ul>"
|
||||||
|
|
||||||
|
for file in semantic_label['files']:
|
||||||
|
filename = file.replace("'", "`")
|
||||||
|
# description = file['changes_in_file']
|
||||||
|
# pr_body += f'- `{filename}`\n'
|
||||||
|
if self.git_provider.is_supported("gfm_markdown"):
|
||||||
|
pr_body += f"<li>{filename}</li>"
|
||||||
|
else:
|
||||||
|
pr_body += f'- `{filename}`\n'
|
||||||
|
if self.git_provider.is_supported("gfm_markdown"):
|
||||||
|
pr_body += "</ul></details>|\n"
|
||||||
else:
|
else:
|
||||||
# if the value is a list, join its items by comma
|
# if the value is a list, join its items by comma
|
||||||
if type(value) == list:
|
if type(value) == list:
|
||||||
|
Reference in New Issue
Block a user