File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,28 @@ function clone
50
50
git checkout " $SHA_TO_TEST "
51
51
echo " Checked out nominal SHA $SHA_TO_TEST for PR $PR_TO_TEST "
52
52
fi
53
- git diff --name-only master HEAD | tee ci-changed-files.txt
53
+ # Get the base branch from PR metadata using GitHub CLI
54
+ git fetch --depth 1 origin
55
+
56
+ BASE_BRANCH=$( gh pr view " $PR_TO_TEST " --json baseRefName --jq ' .baseRefName' 2>&1 )
57
+ if [ -z " $BASE_BRANCH " ]; then
58
+ echo " ERROR: Could not determine base branch for PR $PR_TO_TEST "
59
+ echo " Make sure GitHub CLI (gh) is available and you have access to the repository"
60
+ exit 1
61
+ fi
62
+
63
+ echo " Found base branch from PR metadata: $BASE_BRANCH "
64
+ MERGE_BASE=$( git merge-base HEAD " origin/$BASE_BRANCH " 2> /dev/null || echo " " )
65
+
66
+ # Exit with error if no merge base found
67
+ if [ -z " $MERGE_BASE " ]; then
68
+ echo " ERROR: No merge base found with base branch: $BASE_BRANCH "
69
+ echo " Available remote branches:"
70
+ git branch -r
71
+ exit 1
72
+ else
73
+ git diff --name-only " $MERGE_BASE " HEAD | tee ci-changed-files.txt
74
+ fi
54
75
else
55
76
if [ -v SHA_TO_TEST ]; then
56
77
git fetch --depth 2 origin " $SHA_TO_TEST "
You can’t perform that action at this time.
0 commit comments