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.
This commit is contained in:
jhagen 2019-10-08 11:22:05 +02:00 committed by Darko Poljak
parent 0c7d98e89e
commit 2abc34f922
3 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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
--------

View file

@ -1 +1,2 @@
recursive
shallow