ci: fix static checks merge base resolution
This change fetches the full history of the base branch and the change
under test, to avoid problems with unreachable commits.
Signed-off-by: Chris Kay <chris.kay@arm.com>
Change-Id: I7ed38a65678552fff5b0f5efabf6bafc06ea86ee
Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
diff --git a/script/next-checks/next-checks.sh b/script/next-checks/next-checks.sh
index 39c9d28..4cb0d43 100755
--- a/script/next-checks/next-checks.sh
+++ b/script/next-checks/next-checks.sh
@@ -17,14 +17,19 @@
# next tests, usually this will be main
export GERRIT_BRANCH=${GERRIT_BRANCH:="main"}
+
if [ "$IS_CONTINUOUS_INTEGRATION" == 1 ]; then
- # git operations e.g. ${get_merge_base} rely on access to main branch,
- # we need to access via SSH for that to work currently
+ # git operations rely on access to main branch, we need to access via SSH for that to work currently
SSH_PARAMS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAcceptedKeyTypes=+ssh-rsa -p 29418 -i ${CI_BOT_KEY}"
REPO_SSH_URL="ssh://${CI_BOT_USERNAME}@review.trustedfirmware.org:29418/RF-A/rusted-firmware-a"
export GIT_SSH_COMMAND="ssh ${SSH_PARAMS}"
git remote set-url origin ${REPO_SSH_URL}
- git fetch origin
+ git fetch --unshallow --update-shallow origin
+ git fetch --unshallow --update-shallow origin ${GERRIT_BRANCH} ${GERRIT_REFSPEC}
+
+ export merge_base=$(git merge-base \
+ $(head -n1 .git/FETCH_HEAD | cut -f1) \
+ $(tail -n1 .git/FETCH_HEAD | cut -f1))
fi
# Find the absolute path of the scripts' top directory
@@ -32,17 +37,16 @@
export CI_ROOT=$(pwd)
cd -
-. $CI_ROOT/script/static-checks/common.sh
-
echo
echo "###### Rust checks ######" > "$LOG_TEST_FILENAME"
echo >> "$LOG_TEST_FILENAME"
echo "Patch series being checked:" >> "$LOG_TEST_FILENAME"
-git log --oneline $(get_merge_base)..HEAD >> "$LOG_TEST_FILENAME"
+git log --oneline ${merge_base}..HEAD >> "$LOG_TEST_FILENAME"
echo >> "$LOG_TEST_FILENAME"
echo "Base branch reference commit:" >> "$LOG_TEST_FILENAME"
-git log --oneline -1 $(get_merge_base) >> "$LOG_TEST_FILENAME"
+git log --oneline -1 ${merge_base} >> "$LOG_TEST_FILENAME"
+
echo >> "$LOG_TEST_FILENAME"