Compare commits

...

4 commits

Author SHA1 Message Date
Xinyu Wu
8e88bf065f
Merge 46f889b314 into ede3f82143 2025-11-28 00:17:43 -05:00
Eyal Sharon
ede3f82143 Update documentation to reflect recent changes in enabling configuration scope at group/subgroup levels in gitlab
Some checks failed
Build-and-test / build-and-test (push) Has been cancelled
docs-ci / deploy (push) Has been cancelled
2025-11-27 13:41:45 +02:00
Xinyu Wu
46f889b314
Update test_try_fix_yaml.py
test extract snippet with prefix "```" or "```yml"
2025-11-07 15:43:28 +08:00
Xinyu Wu
3e9b15de15
Update utils.py
more robust try_fix_yaml
2025-11-07 15:30:16 +08:00
3 changed files with 40 additions and 14 deletions

View file

@ -58,7 +58,7 @@ Then you can give a list of extra instructions to the `review` tool.
## Global configuration file 💎
`Platforms supported: GitHub, GitLab, Bitbucket`
`Platforms supported: GitHub, GitLab (cloud), Bitbucket (cloud)`
If you create a repo called `pr-agent-settings` in your **organization**, its configuration file `.pr_agent.toml` will be used as a global configuration file for any other repo that belongs to the same organization.
Parameters from a local `.pr_agent.toml` file, in a specific repo, will override the global configuration parameters.
@ -69,18 +69,21 @@ For example, in the GitHub organization `Codium-ai`:
- The repo [`https://github.com/Codium-ai/pr-agent`](https://github.com/Codium-ai/pr-agent/blob/main/.pr_agent.toml) inherits the global configuration file from `pr-agent-settings`.
### Bitbucket Organization level configuration file 💎
## Project/Group level configuration file 💎
`Platforms supported: GitLab, Bitbucket Data Center`
Create a repository named `pr-agent-settings` within a specific project (Bitbucket) or a group/subgroup (Gitlab).
The configuration file in this repository will apply to all repositories directly under the same project/group/subgroup.
!!! note "Note"
For Gitlab, in case of a repository nested in several sub groups, the lookup for a pr-agent-settings repo will be only on one level above such repository.
## Organization level configuration file 💎
`Relevant platforms: Bitbucket Data Center`
In Bitbucket Data Center, there are two levels where you can define a global configuration file:
- Project-level global configuration:
Create a repository named `pr-agent-settings` within a specific project. The configuration file in this repository will apply to all repositories under the same project.
- Organization-level global configuration:
Create a dedicated project to hold a global configuration file that affects all repositories across all projects in your organization.
**Setting up organization-level global configuration:**

View file

@ -812,14 +812,19 @@ def try_fix_yaml(response_text: str,
pass
# 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))
if not snippet:
snippet = re.search(snippet_pattern, response_text_original) # before we removed the "```"
if snippet:
snippet_text = snippet.group()
prefix = (
'```yaml'
if snippet_text.startswith('```yaml')
else ('```yml' if snippet_text.startswith('```yml') else '```')
)
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")
return data
except:

View file

@ -21,16 +21,34 @@ class TestTryFixYaml:
# The function extracts YAML snippet
def test_extract_snippet(self):
review_text = '''\
review_text1 = '''\
Here is the answer in YAML format:
```yaml
name: John Smith
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}
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.