Skip to content

Commit 5e85119

Browse files
Optimize finding build job for scans (#2898)
Optimize finding build job for scans Reviewed-by: gemini-code-assist[bot] Reviewed-by: Nikola Forró
2 parents 436aa67 + 856851c commit 5e85119

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

packit_service/worker/helpers/open_scan_hub.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,16 @@ def find_base_build_job(self) -> Optional[JobConfig]:
210210
(with `commit` trigger and same branch configured as the target PR branch).
211211
"""
212212
base_build_job = None
213+
target_branch = self.copr_build_helper.pull_request_object.target_branch
214+
default_branch = self.copr_build_helper.project.default_branch
213215

214216
for job in self.copr_build_helper.package_config.get_job_views():
215217
if (
216218
job.type == JobType.copr_build
217219
and job.trigger == JobConfigTriggerType.commit
218220
and (
219-
(
220-
job.branch
221-
and job.branch == self.copr_build_helper.pull_request_object.target_branch
222-
)
223-
or (
224-
not job.branch
225-
and self.copr_build_helper.project.default_branch
226-
== self.copr_build_helper.pull_request_object.target_branch
227-
)
221+
(job.branch and job.branch == target_branch)
222+
or (not job.branch and default_branch == target_branch)
228223
)
229224
):
230225
base_build_job = job

tests/unit/test_open_scan_hub.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def test_handle_scan(build_models):
148148
)
149149

150150
project = flexmock(
151+
default_branch="main",
151152
get_pr=lambda pr_id: flexmock(
152153
target_branch="main",
153154
target_branch_head_commit="abcdef",

0 commit comments

Comments
 (0)