[__git]: Don't generate code only because owner/group is absent

This closes #821 and improves readability.
This commit is contained in:
evilham 2020-06-18 00:12:02 +02:00
parent 14f0780775
commit 05c639e3b7
1 changed files with 7 additions and 4 deletions

View File

@ -38,9 +38,13 @@ mode=$(cat "$__object/parameter/mode")
[ -f "$__object/parameter/recursive" ] && recursive='--recurse-submodules' || recursive=''
[ -f "$__object/parameter/shallow" ] && shallow='--depth 1 --shallow-submodules' || shallow=''
if { [ -n "$owner" ] && [ "$owner_is" != "$owner" ]; } || \
{ [ -n "$group" ] && [ "$group_is" != "$group" ]; }; then
needs_chown="YES"
fi
[ "$state_should" = "$state_is" ] \
&& [ "$owner" = "$owner_is" ] \
&& [ "$group" = "$group_is" ] \
&& [ -z "$needs_chown" ] \
&& [ -n "$mode" ] && exit 0
case $state_should in
@ -48,8 +52,7 @@ case $state_should in
if [ "$state_should" != "$state_is" ]; then
echo git clone --quiet "$recursive" "$shallow" --branch "$branch" "$source" "$destination"
fi
if { [ -n "$owner" ] && [ "$owner_is" != "$owner" ]; } || \
{ [ -n "$group" ] && [ "$group_is" != "$group" ]; }; then
if [ -n "$needs_chown" ]; then
echo chown -R "${owner}:${group}" "$destination"
fi
if [ -f "$__object/parameter/mode-recursive" ]; then