From 770352beb05f63fb9192ad488b6b8344fd57c985 Mon Sep 17 00:00:00 2001 From: jskunda Date: Tue, 18 Jul 2023 09:32:05 +0200 Subject: [PATCH] git: git checkout for a commit hash combinated with depth argument This patch: https://review.opendev.org/c/openstack/devstack/+/882299 provides functionality, that commit hash can be passed as last arugment, however when GIT_DEPTH is set, it fails, as in: timeout -s SIGINT 0 git clone https://github.com/ovn-org/ovn.git ./ovn --depth 1 --branch 03b95a4566a15f7544f4cdf35629dacede4dcf55 fatal: Remote branch 03b95a4566a15f7544f4cdf35629dacede4dcf55 not found in upstream origin Closes-Bug: #2023020 Change-Id: I748354964a133e028e12458cc9014d6d014cbdb9 --- functions-common | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions-common b/functions-common index 63144d6ed7..a668d55b8d 100644 --- a/functions-common +++ b/functions-common @@ -609,9 +609,10 @@ function git_clone { echo "the project to the \$PROJECTS variable in the job definition." die $LINENO "ERROR_ON_CLONE is set to True so cloning not allowed in this configuration" fi - git_timed clone $git_clone_flags $git_remote $git_dest + git_timed clone --no-checkout $git_clone_flags $git_remote $git_dest cd $git_dest - git checkout $git_ref + git_timed fetch $git_clone_flags origin $git_ref + git_timed checkout FETCH_HEAD elif [[ "$RECLONE" = "True" ]]; then # if it does exist then simulate what clone does if asked to RECLONE cd $git_dest