mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-12-12 02:45:18 +00:00
Compare commits
4 commits
8e88bf065f
...
41c1dc18cd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41c1dc18cd | ||
|
|
bf5da9a9fb | ||
|
|
46f889b314 | ||
|
|
3e9b15de15 |
4 changed files with 63 additions and 9 deletions
|
|
@ -56,7 +56,7 @@ A `PR Code Verified` label indicates the PR code meets ticket requirements, but
|
||||||
|
|
||||||
-
|
-
|
||||||
|
|
||||||
By default, the tool will automatically validate if the PR complies with the referenced ticket.
|
By default, the `review` tool will automatically validate if the PR complies with the referenced ticket.
|
||||||
If you want to disable this feedback, add the following line to your configuration file:
|
If you want to disable this feedback, add the following line to your configuration file:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
|
|
@ -75,6 +75,33 @@ A `PR Code Verified` label indicates the PR code meets ticket requirements, but
|
||||||
|
|
||||||
the `review` tool will also validate that the PR code doesn't contain any additional content that is not related to the ticket. If it does, the PR will be labeled at best as `PR Code Verified`, and the `review` tool will provide a comment with the additional unrelated content found in the PR code.
|
the `review` tool will also validate that the PR code doesn't contain any additional content that is not related to the ticket. If it does, the PR will be labeled at best as `PR Code Verified`, and the `review` tool will provide a comment with the additional unrelated content found in the PR code.
|
||||||
|
|
||||||
|
### Compliance tool
|
||||||
|
|
||||||
|
The `compliance` tool also uses ticket context to validate that PR changes fulfill the requirements specified in linked tickets.
|
||||||
|
|
||||||
|
#### Configuration options
|
||||||
|
|
||||||
|
-
|
||||||
|
|
||||||
|
By default, the `compliance` tool will automatically validate if the PR complies with the referenced ticket.
|
||||||
|
If you want to disable ticket compliance checking in the compliance tool, add the following line to your configuration file:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[pr_compliance]
|
||||||
|
require_ticket_analysis_review=false
|
||||||
|
```
|
||||||
|
|
||||||
|
-
|
||||||
|
|
||||||
|
If you set:
|
||||||
|
```toml
|
||||||
|
[pr_compliance]
|
||||||
|
check_pr_additional_content=true
|
||||||
|
```
|
||||||
|
(default: `false`)
|
||||||
|
|
||||||
|
the `compliance` tool will also validate that the PR code doesn't contain any additional content that is not related to the ticket.
|
||||||
|
|
||||||
## GitHub/Gitlab Issues Integration
|
## GitHub/Gitlab Issues Integration
|
||||||
|
|
||||||
Qodo Merge will automatically recognize GitHub/Gitlab issues mentioned in the PR description and fetch the issue content.
|
Qodo Merge will automatically recognize GitHub/Gitlab issues mentioned in the PR description and fetch the issue content.
|
||||||
|
|
|
||||||
|
|
@ -329,6 +329,10 @@ enable_global_pr_compliance = true
|
||||||
???+ example "Ticket compliance options"
|
???+ example "Ticket compliance options"
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><b>require_ticket_analysis_review</b></td>
|
||||||
|
<td>If set to true, the tool will fetch and analyze ticket context for compliance validation. Default is true.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>enable_ticket_labels</b></td>
|
<td><b>enable_ticket_labels</b></td>
|
||||||
<td>If set to true, the tool will add ticket compliance labels to the PR. Default is false.</td>
|
<td>If set to true, the tool will add ticket compliance labels to the PR. Default is false.</td>
|
||||||
|
|
|
||||||
|
|
@ -812,14 +812,19 @@ def try_fix_yaml(response_text: str,
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# second fallback - try to extract only range from first ```yaml to the last ```
|
# second fallback - try to extract only range from first ```yaml to the last ```
|
||||||
snippet_pattern = r'```yaml([\s\S]*?)```(?=\s*$|")'
|
snippet_pattern = r'```(yaml|yml)?([\s\S]*?)```(?=\s*$|")'
|
||||||
snippet = re.search(snippet_pattern, '\n'.join(response_text_lines_copy))
|
snippet = re.search(snippet_pattern, '\n'.join(response_text_lines_copy))
|
||||||
if not snippet:
|
if not snippet:
|
||||||
snippet = re.search(snippet_pattern, response_text_original) # before we removed the "```"
|
snippet = re.search(snippet_pattern, response_text_original) # before we removed the "```"
|
||||||
if snippet:
|
if snippet:
|
||||||
snippet_text = snippet.group()
|
snippet_text = snippet.group()
|
||||||
|
prefix = (
|
||||||
|
'```yaml'
|
||||||
|
if snippet_text.startswith('```yaml')
|
||||||
|
else ('```yml' if snippet_text.startswith('```yml') else '```')
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
data = yaml.safe_load(snippet_text.removeprefix('```yaml').rstrip('`'))
|
data = yaml.safe_load(snippet_text.removeprefix(prefix).rstrip('`'))
|
||||||
get_logger().info(f"Successfully parsed AI prediction after extracting yaml snippet")
|
get_logger().info(f"Successfully parsed AI prediction after extracting yaml snippet")
|
||||||
return data
|
return data
|
||||||
except:
|
except:
|
||||||
|
|
|
||||||
|
|
@ -21,16 +21,34 @@ class TestTryFixYaml:
|
||||||
|
|
||||||
# The function extracts YAML snippet
|
# The function extracts YAML snippet
|
||||||
def test_extract_snippet(self):
|
def test_extract_snippet(self):
|
||||||
review_text = '''\
|
review_text1 = '''\
|
||||||
Here is the answer in YAML format:
|
Here is the answer in YAML format:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: John Smith
|
name: John Smith
|
||||||
age: 35
|
age: 35
|
||||||
```
|
```
|
||||||
|
'''
|
||||||
|
review_text2 = '''\
|
||||||
|
Here is the answer in YAML format:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: John Smith
|
||||||
|
age: 35
|
||||||
|
```
|
||||||
|
'''
|
||||||
|
review_text3 = '''\
|
||||||
|
Here is the answer in YAML format:
|
||||||
|
|
||||||
|
```
|
||||||
|
name: John Smith
|
||||||
|
age: 35
|
||||||
|
```
|
||||||
'''
|
'''
|
||||||
expected_output = {'name': 'John Smith', 'age': 35}
|
expected_output = {'name': 'John Smith', 'age': 35}
|
||||||
assert try_fix_yaml(review_text) == expected_output
|
assert try_fix_yaml(review_text1) == expected_output
|
||||||
|
assert try_fix_yaml(review_text2) == expected_output
|
||||||
|
assert try_fix_yaml(review_text3) == expected_output
|
||||||
|
|
||||||
|
|
||||||
# The YAML string is empty.
|
# The YAML string is empty.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue