mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-12-13 03:15:17 +00:00
in order to have exact sha's we have to find correct diff for this change
otherwise gitlab web doesn't able show diff on page and return 500 or 400 errors based on different scenarios
This commit is contained in:
parent
dee1f168f8
commit
5477469a91
1 changed files with 10 additions and 1 deletions
|
|
@ -155,7 +155,8 @@ class GitLabProvider(GitProvider):
|
|||
if not found:
|
||||
logging.info(f"Could not find position for {relevant_file} {relevant_line_in_file}")
|
||||
else:
|
||||
d = self.last_diff
|
||||
# in order to have exact sha's we have to find correct diff for this change
|
||||
d = self.get_relevant_diff(relevant_file, relevant_line_in_file)
|
||||
pos_obj = {'position_type': 'text',
|
||||
'new_path': target_file.filename,
|
||||
'old_path': target_file.old_filename if target_file.old_filename else target_file.filename,
|
||||
|
|
@ -171,6 +172,14 @@ class GitLabProvider(GitProvider):
|
|||
self.mr.discussions.create({'body': body,
|
||||
'position': pos_obj})
|
||||
|
||||
def get_relevant_diff(self, relevant_file, relevant_line_in_file):
|
||||
for d in self.mr.diffs.list(get_all=True):
|
||||
changes = self.mr.changes() # Retrieve the changes for the merge request
|
||||
for change in changes['changes']:
|
||||
if change['new_path'] == relevant_file and relevant_line_in_file in change['diff']:
|
||||
return d
|
||||
return self.last_diff # fallback to last_diff if no relevant diff is found
|
||||
|
||||
def publish_code_suggestions(self, code_suggestions: list):
|
||||
for suggestion in code_suggestions:
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue