Skip to content

Commit ddb63df

Browse files
committed
[ci] PRs: Check for fork branch name
if identical to the name of the base-ref, error out. Fixes #20743
1 parent d4e54bd commit ddb63df

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

.github/workflows/root-ci-config/build_root.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,18 @@ def main():
5454

5555
pull_request = args.head_ref and args.head_ref != args.base_ref
5656

57-
if not pull_request:
57+
if pull_request:
58+
# We check whether the PR is done from a branch that has the same name of
59+
# the target branch in the ROOT repository using base_ref and head_ref:
60+
# - The base_ref is e.g. "master" or "v6-38-00-patches"
61+
# - The head_ref for PRs is formatted as <PR branch>:<Fork branch> e.g. "refs/pull/20742/head:cppyy_fixup"
62+
if not ":" in args.head_ref:
63+
build_utils.print_error(f"This has been identified as a PR build. However, the head-ref is {args.head_ref}.")
64+
branch_in_fork = args.head_ref.split(":")[-1]
65+
if branch_in_fork == args.base_ref:
66+
build_utils.print_error(f"The branch name in the fork and the base-ref are both called {branch_in_fork}. This is not supported. Please change the name of the branch in the forked repository.")
67+
sys.exit(1)
68+
else:
5869
build_utils.print_info("head_ref same as base_ref, assuming non-PR build")
5970

6071
cleanup_previous_build()

0 commit comments

Comments
 (0)