Compare commits

...

5 commits

Author SHA1 Message Date
YEJI KIM
1f68deae9d
Merge 725a26ba88 into ede3f82143 2025-11-28 02:15:39 +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
isExample
725a26ba88 docs: add inline comments explaining diff marker normalization logic 2025-10-11 02:05:55 +09:00
isExample
1a4df62f89 fix: normalize nested diff markers before YAML parsing 2025-10-11 01:31:31 +09:00
isExample
6561d0478e test: add regression test for diff markers in suggestion blocks 2025-10-11 01:31:06 +09:00
3 changed files with 84 additions and 10 deletions

View file

@ -58,7 +58,7 @@ Then you can give a list of extra instructions to the `review` tool.
## Global configuration file 💎 ## 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. 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. 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`. - 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` `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. 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:** **Setting up organization-level global configuration:**

View file

@ -868,6 +868,44 @@ def try_fix_yaml(response_text: str,
except: except:
pass pass
# 5.5 fallback - try to normalize diff-style removal markers ('-') within list items
response_text_lines_copy = response_text_lines.copy()
modified = False
for i, line in enumerate(response_text_lines_copy):
if line.startswith('+'):
response_text_lines_copy[i] = ' ' + line[1:]
modified = True
# normalize lines starting with '-'. Distinguish real YAML list items from diff deletions.
for i, line in enumerate(response_text_lines_copy):
if not line.startswith('-'):
continue
remainder = line[1:]
if line.startswith('- '):
second_char = remainder[1] if len(remainder) > 1 else ''
if second_char and second_char not in (' ', '\t', '+', '-'):
continue # real list item → keep as-is
# treat it as a diff "removed" marker inside block content
cleaned = remainder
while cleaned and cleaned[0] in ('+', '-'):
cleaned = cleaned[1:]
if cleaned and cleaned[0] not in (' ', '\t'):
cleaned = ' ' + cleaned
if cleaned != line:
response_text_lines_copy[i] = cleaned
modified = True
if modified:
try:
data = yaml.safe_load('\n'.join(response_text_lines_copy))
get_logger().info("Successfully parsed AI prediction after normalizing diff removal markers")
return data
except:
pass
# sixth fallback - replace tabs with spaces # sixth fallback - replace tabs with spaces
if '\t' in response_text: if '\t' in response_text:
response_text_copy = copy.deepcopy(response_text) response_text_copy = copy.deepcopy(response_text)

View file

@ -244,3 +244,36 @@ int sub(int a, int b) {
''' '''
expected_output = {'code_suggestions': [{'relevant_file': 'a.c\n', 'existing_code': ' int sum(int a, int b) {\n return a + b;\n }\n\n int sub(int a, int b) {\n return a - b;\n }\n'}]} expected_output = {'code_suggestions': [{'relevant_file': 'a.c\n', 'existing_code': ' int sum(int a, int b) {\n return a + b;\n }\n\n int sub(int a, int b) {\n return a - b;\n }\n'}]}
assert try_fix_yaml(review_text, first_key='code_suggestions', last_key='existing_code') == expected_output assert try_fix_yaml(review_text, first_key='code_suggestions', last_key='existing_code') == expected_output
def test_diff_markers_removed_within_list_item(self):
"""
Ensures diff-style '-' markers nested inside list items are normalised so the YAML parses
into the expected structure.
"""
review_text = '''\
code_suggestions:
- relevant_file: |
example.rb
existing_code: |
+ puts 'hello'
+ puts 'world'
- relevant_file: |
- example.py
- existing_code: |
-+ print('hello')
-+ print('world')
'''
expected_output = {
'code_suggestions': [
{
'relevant_file': 'example.rb\n',
'existing_code': "puts 'hello'\nputs 'world'\n"
},
{
'relevant_file': 'example.py\n',
'existing_code': "print('hello')\nprint('world')\n"
}
]
}
assert try_fix_yaml(review_text, first_key='code_suggestions', last_key='existing_code') == expected_output