From 292e35c1d9db679446e46de5a283a88382de5518 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Mon, 1 Mar 2021 08:45:47 +0100 Subject: [PATCH] kernel-test: verify REMOTE_NAME and URL If the checked out git repository already has a remote with the name KERNEL_REMOTE_NAME, make sure that the KERNEL_URL matches the remote URL. Motivation for this change is osmo-ci I5d4202a67a24d9c15a5b211fa29ce9d5b5a9d9c1, which will expose the parameters in the jenkins job. Related: OS#3208 Change-Id: I18b29011e3e8e2577bdf1a9c64c4370309cc8399 --- scripts/kernel-test/kernel-build.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/kernel-test/kernel-build.sh b/scripts/kernel-test/kernel-build.sh index d2610516..5f246ae1 100755 --- a/scripts/kernel-test/kernel-build.sh +++ b/scripts/kernel-test/kernel-build.sh @@ -9,6 +9,8 @@ KERNEL_DIR=/cache/linux # Add the kernel repository as git remote, fetch it, checkout the given branch prepare_git_repo() { + local url + if ! [ -d "$KERNEL_DIR" ]; then mkdir -p "$KERNEL_DIR" git -C "$KERNEL_DIR" init @@ -18,6 +20,23 @@ prepare_git_repo() { if ! git remote | grep -q "^$KERNEL_REMOTE_NAME$"; then git remote add "$KERNEL_REMOTE_NAME" "$KERNEL_URL" + else + url="$(git remote get-url "$KERNEL_REMOTE_NAME")" + if [ "$url" != "$KERNEL_URL" ]; then + set +x + echo "ERROR: the checked out repository already has" \ + "a remote with the same name, pointing to a" \ + "different URL!" + echo + echo "KERNEL_REMOTE_NAME: $KERNEL_REMOTE_NAME" + echo "KERNEL_URL (parameter): $KERNEL_URL" + echo "KERNEL_URL (checked out): $url" + echo + echo "Please restart the job, and either change the" \ + "KERNEL_URL parameter to the same value, or" \ + "use a different KERNEL_REMOTE_NAME." + exit 1 + fi fi git fetch "$KERNEL_REMOTE_NAME"