Skip to content

Commit 42557fe

Browse files
committed
Enhance repository filtering with regex pattern matching for ignore_repositories
1 parent d606672 commit 42557fe

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

docs/docs/usage-guide/additional_configurations.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ Qodo Merge allows you to automatically ignore certain PRs based on various crite
164164

165165
- PRs with specific titles (using regex matching)
166166
- PRs between specific branches (using regex matching)
167+
- PRs from specific repositories (using regex matching)
167168
- PRs not from specific folders
168169
- PRs containing specific labels
169170
- PRs opened by specific users
@@ -172,7 +173,7 @@ Qodo Merge allows you to automatically ignore certain PRs based on various crite
172173

173174
To ignore PRs with a specific title such as "[Bump]: ...", you can add the following to your `configuration.toml` file:
174175

175-
```
176+
```toml
176177
[config]
177178
ignore_pr_title = ["\\[Bump\\]"]
178179
```
@@ -183,7 +184,7 @@ Where the `ignore_pr_title` is a list of regex patterns to match the PR title yo
183184

184185
To ignore PRs from specific source or target branches, you can add the following to your `configuration.toml` file:
185186

186-
```
187+
```toml
187188
[config]
188189
ignore_pr_source_branches = ['develop', 'main', 'master', 'stage']
189190
ignore_pr_target_branches = ["qa"]
@@ -192,6 +193,18 @@ ignore_pr_target_branches = ["qa"]
192193
Where the `ignore_pr_source_branches` and `ignore_pr_target_branches` are lists of regex patterns to match the source and target branches you want to ignore.
193194
They are not mutually exclusive, you can use them together or separately.
194195

196+
### Ignoring PRs from specific repositories
197+
198+
To ignore PRs from specific repositories, you can add the following to your `configuration.toml` file:
199+
200+
```toml
201+
[config]
202+
ignore_repositories = ["my-org/my-repo1", "my-org/my-repo2"]
203+
```
204+
205+
Where the `ignore_repositories` is a list of regex patterns to match the repositories you want to ignore. This is useful when you have multiple repositories and want to exclude certain ones from analysis.
206+
207+
195208
### Ignoring PRs not from specific folders
196209

197210
To allow only specific folders (often needed in large monorepos), set:

pr_agent/servers/bitbucket_app.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,17 @@ def should_process_pr_logic(data) -> bool:
129129
sender = _get_username(data)
130130
repo_full_name = pr_data.get("destination", {}).get("repository", {}).get("full_name", "")
131131

132-
print(f"DEBUG: repo_full_name={repo_full_name}, ignore_repos={get_settings().get('CONFIG.IGNORE_REPOSITORIES', [])}")
133132
# logic to ignore PRs from specific repositories
134133
ignore_repos = get_settings().get("CONFIG.IGNORE_REPOSITORIES", [])
135-
if ignore_repos and repo_full_name:
136-
if repo_full_name in ignore_repos:
137-
print(f"DEBUG: Ignoring due to repo match: {repo_full_name}")
134+
if repo_full_name and ignore_repos:
135+
if any(re.search(regex, repo_full_name) for regex in ignore_repos):
138136
get_logger().info(f"Ignoring PR from repository '{repo_full_name}' due to 'config.ignore_repositories' setting")
139137
return False
140138

141139
# logic to ignore PRs from specific users
142140
ignore_pr_users = get_settings().get("CONFIG.IGNORE_PR_AUTHORS", [])
143141
if ignore_pr_users and sender:
144142
if sender in ignore_pr_users:
145-
print(f"DEBUG: Ignoring due to user match: {sender}")
146143
get_logger().info(f"Ignoring PR from user '{sender}' due to 'config.ignore_pr_authors' setting")
147144
return False
148145

@@ -152,25 +149,21 @@ def should_process_pr_logic(data) -> bool:
152149
if not isinstance(ignore_pr_title_re, list):
153150
ignore_pr_title_re = [ignore_pr_title_re]
154151
if ignore_pr_title_re and any(re.search(regex, title) for regex in ignore_pr_title_re):
155-
print(f"DEBUG: Ignoring due to title match: {title}")
156152
get_logger().info(f"Ignoring PR with title '{title}' due to config.ignore_pr_title setting")
157153
return False
158154

159155
ignore_pr_source_branches = get_settings().get("CONFIG.IGNORE_PR_SOURCE_BRANCHES", [])
160156
ignore_pr_target_branches = get_settings().get("CONFIG.IGNORE_PR_TARGET_BRANCHES", [])
161157
if (ignore_pr_source_branches or ignore_pr_target_branches):
162158
if any(re.search(regex, source_branch) for regex in ignore_pr_source_branches):
163-
print(f"DEBUG: Ignoring due to source branch match: {source_branch}")
164159
get_logger().info(
165160
f"Ignoring PR with source branch '{source_branch}' due to config.ignore_pr_source_branches settings")
166161
return False
167162
if any(re.search(regex, target_branch) for regex in ignore_pr_target_branches):
168-
print(f"DEBUG: Ignoring due to target branch match: {target_branch}")
169163
get_logger().info(
170164
f"Ignoring PR with target branch '{target_branch}' due to config.ignore_pr_target_branches settings")
171165
return False
172166
except Exception as e:
173-
print(f"DEBUG: Exception in should_process_pr_logic: {e}")
174167
get_logger().error(f"Failed 'should_process_pr_logic': {e}")
175168
print("DEBUG: Returning True from should_process_pr_logic")
176169
return True

pr_agent/servers/github_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def should_process_pr_logic(body) -> bool:
263263
# logic to ignore PRs from specific repositories
264264
ignore_repos = get_settings().get("CONFIG.IGNORE_REPOSITORIES", [])
265265
if ignore_repos and repo_full_name:
266-
if repo_full_name in ignore_repos:
266+
if any(re.search(regex, repo_full_name) for regex in ignore_repos):
267267
get_logger().info(f"Ignoring PR from repository '{repo_full_name}' due to 'config.ignore_repositories' setting")
268268
return False
269269

pr_agent/servers/gitlab_webhook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def should_process_pr_logic(data) -> bool:
108108
# logic to ignore PRs from specific repositories
109109
ignore_repos = get_settings().get("CONFIG.IGNORE_REPOSITORIES", [])
110110
if ignore_repos and repo_full_name:
111-
if repo_full_name in ignore_repos:
111+
if any(re.search(regex, repo_full_name) for regex in ignore_repos):
112112
get_logger().info(f"Ignoring MR from repository '{repo_full_name}' due to 'config.ignore_repositories' setting")
113113
return False
114114

pr_agent/settings/configuration.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ignore_pr_target_branches = [] # a list of regular expressions of target branche
5555
ignore_pr_source_branches = [] # a list of regular expressions of source branches to ignore from PR agent when an PR is created
5656
ignore_pr_labels = [] # labels to ignore from PR agent when an PR is created
5757
ignore_pr_authors = [] # authors to ignore from PR agent when an PR is created
58-
ignore_repositories = [] # list of repository full names (e.g. "org/repo") to ignore from PR agent processing
58+
ignore_repositories = [] # a list of regular expressions of repository full names (e.g. "org/repo") to ignore from PR agent processing
5959
#
6060
is_auto_command = false # will be auto-set to true if the command is triggered by an automation
6161
enable_ai_metadata = false # will enable adding ai metadata

0 commit comments

Comments
 (0)