|
...
|
...
|
@@ -19,6 +19,7 @@
|
|
19
|
19
|
#
|
|
20
|
20
|
# The following variables are assumed to be defined by certain functions:
|
|
21
|
21
|
#
|
|
|
22
|
+# - ``GIT_DEPTH``
|
|
22
|
23
|
# - ``ENABLED_SERVICES``
|
|
23
|
24
|
# - ``ERROR_ON_CLONE``
|
|
24
|
25
|
# - ``FILES``
|
|
...
|
...
|
@@ -562,16 +563,22 @@ function get_release_name_from_branch {
|
|
562
|
562
|
# Set global ``RECLONE=yes`` to simulate a clone when dest-dir exists
|
|
563
|
563
|
# Set global ``ERROR_ON_CLONE=True`` to abort execution with an error if the git repo
|
|
564
|
564
|
# does not exist (default is False, meaning the repo will be cloned).
|
|
565
|
|
-# Uses globals ``ERROR_ON_CLONE``, ``OFFLINE``, ``RECLONE``
|
|
|
565
|
+# Set global ``GIT_DEPTH=<number>`` to limit the history depth of the git clone
|
|
|
566
|
+# Uses globals ``ERROR_ON_CLONE``, ``OFFLINE``, ``RECLONE``, ``GIT_DEPTH``
|
|
566
|
567
|
# git_clone remote dest-dir branch
|
|
567
|
568
|
function git_clone {
|
|
568
|
569
|
local git_remote=$1
|
|
569
|
570
|
local git_dest=$2
|
|
570
|
571
|
local git_ref=$3
|
|
571
|
572
|
local orig_dir=$(pwd)
|
|
|
573
|
+ local git_clone_flags=""
|
|
572
|
574
|
|
|
573
|
575
|
RECLONE=$(trueorfalse False $RECLONE)
|
|
574
|
576
|
|
|
|
577
|
+ if [[ "$GIT_DEPTH" ]]; then
|
|
|
578
|
+ git_clone_flags="$git_clone_flags --depth $GIT_DEPTH"
|
|
|
579
|
+ fi
|
|
|
580
|
+
|
|
575
|
581
|
if [[ "$OFFLINE" = "True" ]]; then
|
|
576
|
582
|
echo "Running in offline mode, clones already exist"
|
|
577
|
583
|
# print out the results so we know what change was used in the logs
|
|
...
|
...
|
@@ -586,7 +593,7 @@ function git_clone {
|
|
586
|
586
|
if [[ ! -d $git_dest ]]; then
|
|
587
|
587
|
[[ "$ERROR_ON_CLONE" = "True" ]] && \
|
|
588
|
588
|
die $LINENO "Cloning not allowed in this configuration"
|
|
589
|
|
- git_timed clone $git_remote $git_dest
|
|
|
589
|
+ git_timed clone $git_clone_flags $git_remote $git_dest
|
|
590
|
590
|
fi
|
|
591
|
591
|
cd $git_dest
|
|
592
|
592
|
git_timed fetch $git_remote $git_ref && git checkout FETCH_HEAD
|
|
...
|
...
|
@@ -595,7 +602,7 @@ function git_clone {
|
|
595
|
595
|
if [[ ! -d $git_dest ]]; then
|
|
596
|
596
|
[[ "$ERROR_ON_CLONE" = "True" ]] && \
|
|
597
|
597
|
die $LINENO "Cloning not allowed in this configuration"
|
|
598
|
|
- git_timed clone $git_remote $git_dest
|
|
|
598
|
+ git_timed clone $git_clone_flags $git_remote $git_dest
|
|
599
|
599
|
cd $git_dest
|
|
600
|
600
|
# This checkout syntax works for both branches and tags
|
|
601
|
601
|
git checkout $git_ref
|