From 2abc34f92236d272f29cd8029bdec7fea8ae6455 Mon Sep 17 00:00:00 2001 From: Jonas Hagen Date: Tue, 8 Oct 2019 11:22:05 +0200 Subject: [PATCH] Add --shallow option Provides the capability to make shallow clones (including submodules) to deploy repositories with huge history. Note that this might not work with some servers (github.com) if the commit that is required by a submodule is too far away from any reference. --- cdist/conf/type/__git/gencode-remote | 3 ++- cdist/conf/type/__git/man.rst | 4 ++++ cdist/conf/type/__git/parameter/boolean | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__git/gencode-remote b/cdist/conf/type/__git/gencode-remote index a36ff5cd..ab22655f 100755 --- a/cdist/conf/type/__git/gencode-remote +++ b/cdist/conf/type/__git/gencode-remote @@ -36,6 +36,7 @@ group=$(cat "$__object/parameter/group") mode=$(cat "$__object/parameter/mode") [ -f "$__object/parameter/recursive" ] && recursive='--recurse-submodules' || recursive='' +[ -f "$__object/parameter/shallow" ] && shallow='--depth 1 --shallow-submodules' || shallow='' [ "$state_should" = "$state_is" ] \ && [ "$owner" = "$owner_is" ] \ @@ -45,7 +46,7 @@ mode=$(cat "$__object/parameter/mode") case $state_should in present) if [ "$state_should" != "$state_is" ]; then - echo git clone --quiet "$recursive" --branch "$branch" "$source" "$destination" + echo git clone --quiet "$recursive" "$shallow" --branch "$branch" "$source" "$destination" fi if { [ -n "$owner" ] && [ "$owner_is" != "$owner" ]; } || \ { [ -n "$group" ] && [ "$group_is" != "$group" ]; }; then diff --git a/cdist/conf/type/__git/man.rst b/cdist/conf/type/__git/man.rst index f18a5a0e..d3e15f25 100644 --- a/cdist/conf/type/__git/man.rst +++ b/cdist/conf/type/__git/man.rst @@ -38,6 +38,10 @@ owner recursive Passes the --recurse-submodules flag to git when cloning the repository. +shallow + Sets --depth=1 and --shallow-submodules for cloning repositories with big history. + + EXAMPLES -------- diff --git a/cdist/conf/type/__git/parameter/boolean b/cdist/conf/type/__git/parameter/boolean index a633e659..d600d4ca 100644 --- a/cdist/conf/type/__git/parameter/boolean +++ b/cdist/conf/type/__git/parameter/boolean @@ -1 +1,2 @@ recursive +shallow