clone.sh: only checkout topic for other repos
If a Gerrit topic is available, the clone script will always checkout
the tip of the topic in all the repositories. This means that when a
Gerrit review triggers the CI, the full topic will always be verified,
which may cause the review that triggered the CI to fail the
verification because there was an issue with one of the later reviews in
the topic chain.
To make it possible to verify a specific review in the topic chain, the
clone script will now checkout the specific review that triggered the
job and then only use the topic to checkout the other repositories.
Signed-off-by: Mikael Olsson <mikael.olsson@arm.com>
Change-Id: Icf747351b6cd9f0980840179148db22eed6638e2
diff --git a/scripts/clone.sh b/scripts/clone.sh
index 2eac7bb..d984a66 100755
--- a/scripts/clone.sh
+++ b/scripts/clone.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
-# Copyright (c) 2021-2022 Arm Limited. All rights reserved.
+# Copyright (c) 2021-2023 Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -93,8 +93,8 @@
if [ ! -d ${SHARE_FOLDER}/${REPO_NAME} ]; then
git clone ${GIT_CLONE_PARAMS} ${REPO_URL} ${SHARE_FOLDER}/${REPO_NAME}
- # Repo synchronization
- if [ -n "${GERRIT_TOPIC}" -a "${REPO_HOST}" = "${GERRIT_HOST}" ]; then
+ # If the Gerrit review that triggered the CI had a topic, it will be used to synchronize the other repositories
+ if [ -n "${GERRIT_TOPIC}" -a "${REPO_HOST}" = "${GERRIT_HOST}" -a "${GERRIT_PROJECT}" != "${REPO_PROJECT}" ]; then
echo "Got Gerrit Topic: ${GERRIT_TOPIC}"
REPO_REFSPEC="$(ssh ${SSH_PARAMS} ${CI_BOT_USERNAME}@${REPO_HOST#https://} gerrit query ${GERRIT_QUERY_PARAMS} \
project:${REPO_PROJECT} topic:${GERRIT_TOPIC} | ${SHARE_FOLDER}/${JOBS_REPO_NAME}/scripts/parse_refspec.py || true)"