mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-14 01:30:37 +08:00
Merge pull request #1125 from Codium-ai/tr/err_protections
Tr/err protections
This commit is contained in:
@ -33,9 +33,29 @@ def filter_ignored(files, platform = 'github'):
|
|||||||
if platform == 'github':
|
if platform == 'github':
|
||||||
files = [f for f in files if (f.filename and not r.match(f.filename))]
|
files = [f for f in files if (f.filename and not r.match(f.filename))]
|
||||||
elif platform == 'bitbucket':
|
elif platform == 'bitbucket':
|
||||||
files = [f for f in files if (f.new.path and not r.match(f.new.path))]
|
# files = [f for f in files if (f.new.path and not r.match(f.new.path))]
|
||||||
|
files_o = []
|
||||||
|
for f in files:
|
||||||
|
if hasattr(f, 'new'):
|
||||||
|
if f.new and f.new.path and not r.match(f.new.path):
|
||||||
|
files_o.append(f)
|
||||||
|
continue
|
||||||
|
if hasattr(f, 'old'):
|
||||||
|
if f.old and f.old.path and not r.match(f.old.path):
|
||||||
|
files_o.append(f)
|
||||||
|
continue
|
||||||
|
files = files_o
|
||||||
elif platform == 'gitlab':
|
elif platform == 'gitlab':
|
||||||
files = [f for f in files if (f['new_path'] and not r.match(f['new_path']))]
|
# files = [f for f in files if (f['new_path'] and not r.match(f['new_path']))]
|
||||||
|
files_o = []
|
||||||
|
for f in files:
|
||||||
|
if 'new_path' in f and f['new_path'] and not r.match(f['new_path']):
|
||||||
|
files_o.append(f)
|
||||||
|
continue
|
||||||
|
if 'old_path' in f and f['old_path'] and not r.match(f['old_path']):
|
||||||
|
files_o.append(f)
|
||||||
|
continue
|
||||||
|
files = files_o
|
||||||
elif platform == 'azure':
|
elif platform == 'azure':
|
||||||
files = [f for f in files if not r.match(f)]
|
files = [f for f in files if not r.match(f)]
|
||||||
|
|
||||||
|
@ -134,10 +134,13 @@ class BitbucketProvider(GitProvider):
|
|||||||
if diffs != diffs_original:
|
if diffs != diffs_original:
|
||||||
try:
|
try:
|
||||||
names_original = [d.new.path for d in diffs_original]
|
names_original = [d.new.path for d in diffs_original]
|
||||||
names_filtered = [d.new.path for d in diffs]
|
names_kept = [d.new.path for d in diffs]
|
||||||
|
names_filtered = list(set(names_original) - set(names_kept))
|
||||||
get_logger().info(f"Filtered out [ignore] files for PR", extra={
|
get_logger().info(f"Filtered out [ignore] files for PR", extra={
|
||||||
'original_files': names_original,
|
'original_files': names_original,
|
||||||
'filtered_files': names_filtered
|
'names_kept': names_kept,
|
||||||
|
'names_filtered': names_filtered
|
||||||
|
|
||||||
})
|
})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
@ -145,6 +148,9 @@ class BitbucketProvider(GitProvider):
|
|||||||
# get the pr patches
|
# get the pr patches
|
||||||
pr_patch = self.pr.diff()
|
pr_patch = self.pr.diff()
|
||||||
diff_split = ["diff --git" + x for x in pr_patch.split("diff --git") if x.strip()]
|
diff_split = ["diff --git" + x for x in pr_patch.split("diff --git") if x.strip()]
|
||||||
|
# filter all elements of 'diff_split' that are of indices in 'diffs_original' that are not in 'diffs'
|
||||||
|
if len(diff_split) > len(diffs) and len(diffs_original) == len(diff_split):
|
||||||
|
diff_split = [diff_split[i] for i in range(len(diff_split)) if diffs_original[i] in diffs]
|
||||||
if len(diff_split) != len(diffs):
|
if len(diff_split) != len(diffs):
|
||||||
get_logger().error(f"Error - failed to split the diff into {len(diffs)} parts")
|
get_logger().error(f"Error - failed to split the diff into {len(diffs)} parts")
|
||||||
return []
|
return []
|
||||||
|
Reference in New Issue
Block a user