Merge pull request #83 from Codium-ai/hl/gitlab_description

Support describe for Gitlab
This commit is contained in:
Hussam Lawen
2023-07-18 13:47:32 +03:00
committed by GitHub
5 changed files with 12 additions and 8 deletions

View File

@ -76,7 +76,7 @@ To set up your own PR-Agent, see the [Quickstart](#Quickstart) section
| TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | | TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| | ⮑ Inline review | :white_check_mark: | :white_check_mark: | | | | ⮑ Inline review | :white_check_mark: | :white_check_mark: | |
| | Ask | :white_check_mark: | :white_check_mark: | | | | Ask | :white_check_mark: | :white_check_mark: | |
| | Auto-Description | :white_check_mark: | | | | | Auto-Description | :white_check_mark: | :white_check_mark: | |
| | Improve Code | :white_check_mark: | :white_check_mark: | | | | Improve Code | :white_check_mark: | :white_check_mark: | |
| | Reflect and Review | :white_check_mark: | | | | | Reflect and Review | :white_check_mark: | | |
| | | | | | | | | | | |

View File

@ -29,10 +29,10 @@ def get_pr_diff(git_provider: Union[GithubProvider, Any], token_handler: TokenHa
global PATCH_EXTRA_LINES global PATCH_EXTRA_LINES
PATCH_EXTRA_LINES = 0 PATCH_EXTRA_LINES = 0
git_provider.pr.diff_files = list(git_provider.get_diff_files()) diff_files = list(git_provider.get_diff_files())
# get pr languages # get pr languages
pr_languages = sort_files_by_main_languages(git_provider.get_languages(), git_provider.pr.diff_files) pr_languages = sort_files_by_main_languages(git_provider.get_languages(), diff_files)
# generate a standard diff string, with patch extension # generate a standard diff string, with patch extension
patches_extended, total_tokens = pr_generate_extended_diff(pr_languages, token_handler, patches_extended, total_tokens = pr_generate_extended_diff(pr_languages, token_handler,

View File

@ -70,7 +70,7 @@ class GithubProvider(GitProvider):
if relevant_line_in_file in line: if relevant_line_in_file in line:
position = i position = i
break break
elif relevant_line_in_file[0] == '+' and relevant_line_in_file[1:] in line: elif relevant_line_in_file[0] == '+' and relevant_line_in_file[1:].lstrip() in line:
# The model often adds a '+' to the beginning of the relevant_line_in_file even if originally # The model often adds a '+' to the beginning of the relevant_line_in_file even if originally
# it's a context line # it's a context line
position = i position = i

View File

@ -87,8 +87,12 @@ class GitLabProvider(GitProvider):
return [change['new_path'] for change in self.mr.changes()['changes']] return [change['new_path'] for change in self.mr.changes()['changes']]
def publish_description(self, pr_title: str, pr_body: str): def publish_description(self, pr_title: str, pr_body: str):
logging.exception("Not implemented yet") try:
pass self.mr.title = pr_title
self.mr.description = pr_body
self.mr.save()
except Exception as e:
logging.exception(f"Could not update merge request {self.id_mr} description: {e}")
def publish_comment(self, mr_comment: str, is_temporary: bool = False): def publish_comment(self, mr_comment: str, is_temporary: bool = False):
comment = self.mr.notes.create({'body': mr_comment}) comment = self.mr.notes.create({'body': mr_comment})
@ -187,7 +191,7 @@ class GitLabProvider(GitProvider):
found = True found = True
edit_type = self.get_edit_type(line) edit_type = self.get_edit_type(line)
break break
elif relevant_line_in_file[0] == '+' and relevant_line_in_file[1:] in line: elif relevant_line_in_file[0] == '+' and relevant_line_in_file[1:].lstrip() in line:
# The model often adds a '+' to the beginning of the relevant_line_in_file even if originally # The model often adds a '+' to the beginning of the relevant_line_in_file even if originally
# it's a context line # it's a context line
found = True found = True

View File

@ -96,7 +96,7 @@ class PRReviewer:
del data['PR Feedback']['Security concerns'] del data['PR Feedback']['Security concerns']
data['PR Analysis']['Security concerns'] = val data['PR Analysis']['Security concerns'] = val
if settings.config.git_provider == 'github' and \ if settings.config.git_provider != 'bitbucket' and \
settings.pr_reviewer.inline_code_comments and \ settings.pr_reviewer.inline_code_comments and \
'Code suggestions' in data['PR Feedback']: 'Code suggestions' in data['PR Feedback']:
# keeping only code suggestions that can't be submitted as inline comments # keeping only code suggestions that can't be submitted as inline comments