File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 2
2
3
3
source ./hooks/populate-hook-constants.sh
4
4
5
- isVersionBranch=$( if [[ ${currentBranch } =~ ^[0-9]+.[0-9]+$ ]]; then echo true ; else echo false ; fi )
5
+ isVersionBranch=$( if [[ ${targetBranch } =~ ^[0-9]+.[0-9]+$ ]]; then echo true ; else echo false ; fi )
6
6
7
7
# Check that the code version matches the branch version if on a versioned branch
8
8
# `%.*` strips out the suffix after (and including) the last `.`
9
- if " $isVersionBranch " && [[ " ${currentBranch % .* } " != " ${newestVersion% .* } " ]]
9
+ if " $isVersionBranch " && [[ " ${targetBranch % .* } " != " ${newestVersion% .* } " ]]
10
10
then
11
- echo " Code version (${newestVersion% .* } ) does not match branch (${currentBranch % .* } ), unexpected."
11
+ echo " Code version (${newestVersion% .* } ) does not match branch (${targetBranch % .* } ), unexpected."
12
12
exit 1
13
13
fi
Original file line number Diff line number Diff line change @@ -9,5 +9,12 @@ setupVersion=$(sed -n 's/ *version *= *["]\([0-9\.]*\).*/\1/p' setup.py )
9
9
10
10
newestVersion=$( if [[ " $constantsVersion " > " $setupVersion " ]]; then echo " $constantsVersion " ; else echo " $setupVersion " ; fi )
11
11
12
- currentBranch=$( git branch --show-current 2> /dev/null) || currentBranch=" (unnamed branch)" # Get current branch
13
- currentBranch=${currentBranch## refs/ heads/ } # Remove refs/heads/ if present
12
+ # Target branch of the PR.
13
+ # Ideally, this is all we want to check.
14
+ if [[ " $GITHUB_BASE_REF " != " " ]]
15
+ then
16
+ targetBranch=" $GITHUB_BASE_REF "
17
+ else # Fallback to current branch if not in a PR
18
+ targetBranch=$( git branch --show-current 2> /dev/null) || targetBranch=" (unnamed branch)" # Get current branch
19
+ fi
20
+ targetBranch=${targetBranch## refs/ heads/ } # Remove refs/heads/ if present
You can’t perform that action at this time.
0 commit comments