mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 12:20:38 +08:00
Refactor Azure DevOps provider to use PR iterations for change detection, improving accuracy of diff file identification
This commit is contained in:
@ -356,7 +356,7 @@ def convert_str_to_datetime(date_str):
|
|||||||
return datetime.strptime(date_str, datetime_format)
|
return datetime.strptime(date_str, datetime_format)
|
||||||
|
|
||||||
|
|
||||||
def load_large_diff(filename, new_file_content_str: str, original_file_content_str: str) -> str:
|
def load_large_diff(filename, new_file_content_str: str, original_file_content_str: str, show_warning: bool = True) -> str:
|
||||||
"""
|
"""
|
||||||
Generate a patch for a modified file by comparing the original content of the file with the new content provided as
|
Generate a patch for a modified file by comparing the original content of the file with the new content provided as
|
||||||
input.
|
input.
|
||||||
@ -375,7 +375,7 @@ def load_large_diff(filename, new_file_content_str: str, original_file_content_s
|
|||||||
try:
|
try:
|
||||||
diff = difflib.unified_diff(original_file_content_str.splitlines(keepends=True),
|
diff = difflib.unified_diff(original_file_content_str.splitlines(keepends=True),
|
||||||
new_file_content_str.splitlines(keepends=True))
|
new_file_content_str.splitlines(keepends=True))
|
||||||
if get_settings().config.verbosity_level >= 2:
|
if get_settings().config.verbosity_level >= 2 and show_warning:
|
||||||
get_logger().warning(f"File was modified, but no patch was found. Manually creating patch: {filename}.")
|
get_logger().warning(f"File was modified, but no patch was found. Manually creating patch: {filename}.")
|
||||||
patch = ''.join(diff)
|
patch = ''.join(diff)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -237,12 +237,12 @@ class AzureDevopsProvider(GitProvider):
|
|||||||
pull_request_id=self.pr_num,
|
pull_request_id=self.pr_num,
|
||||||
project=self.workspace_slug
|
project=self.workspace_slug
|
||||||
)
|
)
|
||||||
changes = []
|
changes = None
|
||||||
if iterations:
|
if iterations:
|
||||||
iteration_id = iterations[-1].id # Get the last iteration (most recent changes)
|
iteration_id = iterations[-1].id # Get the last iteration (most recent changes)
|
||||||
|
|
||||||
# Get changes for the iteration
|
# Get changes for the iteration
|
||||||
changes: GitPullRequestIterationChanges = self.azure_devops_client.get_pull_request_iteration_changes(
|
changes = self.azure_devops_client.get_pull_request_iteration_changes(
|
||||||
repository_id=self.repo_slug,
|
repository_id=self.repo_slug,
|
||||||
pull_request_id=self.pr_num,
|
pull_request_id=self.pr_num,
|
||||||
iteration_id=iteration_id,
|
iteration_id=iteration_id,
|
||||||
@ -336,8 +336,8 @@ class AzureDevopsProvider(GitProvider):
|
|||||||
original_file_content_str = ""
|
original_file_content_str = ""
|
||||||
|
|
||||||
patch = load_large_diff(
|
patch = load_large_diff(
|
||||||
file, new_file_content_str, original_file_content_str
|
file, new_file_content_str, original_file_content_str, show_warning=False
|
||||||
)
|
).rstrip()
|
||||||
|
|
||||||
diff_files.append(
|
diff_files.append(
|
||||||
FilePatchInfo(
|
FilePatchInfo(
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
model="gpt-4-turbo-2024-04-09"
|
model="gpt-4-turbo-2024-04-09"
|
||||||
model_turbo="gpt-4-turbo-2024-04-09"
|
model_turbo="gpt-4-turbo-2024-04-09"
|
||||||
fallback_models=["gpt-4-0125-preview"]
|
fallback_models=["gpt-4-0125-preview"]
|
||||||
git_provider="github"
|
git_provider="azure"
|
||||||
publish_output=true
|
publish_output=false
|
||||||
publish_output_progress=true
|
publish_output_progress=true
|
||||||
verbosity_level=0 # 0,1,2
|
verbosity_level=2 # 0,1,2
|
||||||
use_extra_bad_extensions=false
|
use_extra_bad_extensions=false
|
||||||
use_wiki_settings_file=true
|
use_wiki_settings_file=true
|
||||||
use_repo_settings_file=true
|
use_repo_settings_file=true
|
||||||
@ -80,7 +80,7 @@ enable_help_text=false
|
|||||||
[pr_code_suggestions] # /improve #
|
[pr_code_suggestions] # /improve #
|
||||||
max_context_tokens=8000
|
max_context_tokens=8000
|
||||||
num_code_suggestions=4
|
num_code_suggestions=4
|
||||||
commitable_code_suggestions = false
|
commitable_code_suggestions = true
|
||||||
extra_instructions = ""
|
extra_instructions = ""
|
||||||
rank_suggestions = false
|
rank_suggestions = false
|
||||||
enable_help_text=false
|
enable_help_text=false
|
||||||
|
Reference in New Issue
Block a user