Skip to content

Commit b3ee477

Browse files
authored
Close #390: Ignore !buildbot comment if no builder matches (#400)
Also, match the regex anywhere in the builder name, not only at the start.
1 parent c2025a7 commit b3ee477

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

master/custom/pr_testing.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,20 @@ def handle_issue_comment(self, payload, event):
255255
return ([], "git")
256256

257257
builder_filter_fn = re.compile(builder_filter)
258+
matched_builders = [
259+
builder
260+
for builder in self.builder_names
261+
if builder_filter_fn.search(builder)
262+
]
263+
if not matched_builders:
264+
log.msg(f"GitHub PR #{number}: regex {builder_filter!r} "
265+
f"did not match any builder", logLevel=logging.DEBUG)
266+
yield self._post_comment(
267+
payload["issue"]["comments_url"],
268+
"The regex {builder_filter!r} did not match any buildbot builder",
269+
)
270+
return (changes, "git")
271+
258272
yield self._post_comment(
259273
payload["issue"]["comments_url"],
260274
BUILD_COMMAND_SCHEDULED_MESSAGE.format(
@@ -264,8 +278,7 @@ def handle_issue_comment(self, payload, event):
264278
builders="\n".join(
265279
{
266280
f"- `{builder}`"
267-
for builder in self.builder_names
268-
if builder_filter_fn.match(builder)
281+
for builder in matched_builders
269282
}
270283
),
271284
),

master/custom/schedulers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def addBuildsetForChanges(self, **kwargs):
2626
builder_names = [
2727
builder_name
2828
for builder_name in builder_names
29-
if matcher.match(builder_name)
29+
if matcher.search(builder_name)
3030
]
31-
log.msg("Bulder names filtered: {}".format(builder_names))
31+
log.msg(f"Builder names filtered: {builder_names}")
3232
kwargs.update(builderNames=builder_names)
3333
yield super().addBuildsetForChanges(**kwargs)
3434
return

0 commit comments

Comments
 (0)