Skip to content

Commit 95d6f3f

Browse files
rzrydirson
andcommitted
koji: Handle undeclared branches differently than empty set...
Which is semantically different, as explained in review but from user perspective both will fail (but logs will be more accurate). Also relocate the smaller scope closer to test, for readability. Relate-to: #774 (comment) Co-authored-by: Yann Dirson <yann.dirson@vates.tech> Signed-off-by: Philippe Coval <philippe.coval@vates.tech>
1 parent 6b96faf commit 95d6f3f

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

scripts/koji/koji_build.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,18 @@ def check_commit_is_available_remotely(dirpath, hash, target, warn):
5454
raise Exception("Building with a user target requires using --pre-build or --test-build.\n")
5555
try:
5656
supported_branches = PROTECTED_TARGETS.get(target)
57-
if supported_branches:
58-
for branch in supported_branches:
59-
try:
60-
if is_remote_branch_commit(dirpath, hash, branch):
61-
logging.debug(f"commit {hash} is on top of branch {branch} (target: {target})")
62-
break
63-
except Exception as e:
64-
logging.debug(f"{e} Ignoring")
65-
else:
66-
raise Exception(f"The current commit is not the last commit of any remote branches {supported_branches}.\n"
67-
f"This is required when using the protected target {target}.")
68-
else:
57+
if supported_branches is None:
6958
raise Exception(f"Protected target {target} has no allowed branches.")
59+
for branch in supported_branches:
60+
try:
61+
if is_remote_branch_commit(dirpath, hash, branch):
62+
logging.debug(f"commit {hash} is on top of branch {branch} (target: {target})")
63+
break
64+
except Exception as e:
65+
logging.debug(f"{e} Ignoring")
66+
else:
67+
raise Exception(f"The current commit is not the last commit of any remote branches {supported_branches}.\n"
68+
f"This is required when using the protected target {target}.")
7069
except Exception as e:
7170
if warn:
7271
print(f"warning: {e}", flush=True)

0 commit comments

Comments
 (0)