parent
852ac22b13
commit
a40025d842
4 changed files with 33 additions and 1 deletions
|
@ -71,16 +71,24 @@ EOF
|
||||||
fi
|
fi
|
||||||
# Actually clone the repository
|
# Actually clone the repository
|
||||||
su -m "$git_user" -c "git clone --quiet '$recursive' '$shallow' --branch '$branch' '$source' '$destination'"
|
su -m "$git_user" -c "git clone --quiet '$recursive' '$shallow' --branch '$branch' '$source' '$destination'"
|
||||||
|
echo create >> "$__messages_out"
|
||||||
|
repo_changed="YES"
|
||||||
elif [ "$branch_should" != "$branch_is" ]; then
|
elif [ "$branch_should" != "$branch_is" ]; then
|
||||||
# User has changed tag / branch, let's update that
|
# User has changed tag / branch, let's update that
|
||||||
echo su -m "$git_user" -c "git checkout '$branch_should'"
|
echo su -m "$git_user" -c "git checkout '$branch_should'"
|
||||||
|
echo "change $branch_is -> $branch_should" >> "$__messages_out"
|
||||||
|
repo_changed="YES"
|
||||||
elif [ "$needs_update" = "YES" ]; then
|
elif [ "$needs_update" = "YES" ]; then
|
||||||
# The remote has newer information than our repository.
|
# The remote has newer information than our repository.
|
||||||
# Fetch was done in the explorer, here we can just pull
|
# Fetch was done in the explorer, here we can just pull
|
||||||
echo su -m "$git_user" -c "git -C '$destination' pull"
|
echo su -m "$git_user" -c "git -C '$destination' pull"
|
||||||
|
echo update >> "$__messages_out"
|
||||||
|
repo_changed="YES"
|
||||||
fi
|
fi
|
||||||
if [ -n "$needs_chown" ]; then
|
if [ -n "$needs_chown" ]; then
|
||||||
echo chown -R "${owner}:${group}" "$destination"
|
echo chown -R "${owner}:${group}" "$destination"
|
||||||
|
echo "chown -R '${owner}:${group}'" >> "$__messages_out"
|
||||||
|
repo_changed="YES"
|
||||||
fi
|
fi
|
||||||
if [ -f "$__object/parameter/mode-recursive" ]; then
|
if [ -f "$__object/parameter/mode-recursive" ]; then
|
||||||
mode_recursive="-R"
|
mode_recursive="-R"
|
||||||
|
@ -91,7 +99,11 @@ EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
absent)
|
absent)
|
||||||
# Handled in manifest
|
# Handled in manifest, except for the change triggers
|
||||||
|
if [ "$state_should" != "$state_is" ]; then
|
||||||
|
echo remove >> "$__messages_out"
|
||||||
|
repo_changed="YES"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
|
@ -99,3 +111,7 @@ EOF
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if [ -n "$repo_changed" ]; then
|
||||||
|
cat "$__object/parameter/onchange"
|
||||||
|
fi
|
||||||
|
|
|
@ -35,6 +35,9 @@ mode
|
||||||
By default it only applies to the top-level directory.
|
By default it only applies to the top-level directory.
|
||||||
See the mode-recursive parameter as well.
|
See the mode-recursive parameter as well.
|
||||||
|
|
||||||
|
onchange
|
||||||
|
The code to run if the repository is first-cloned, changes or is removed.
|
||||||
|
|
||||||
owner
|
owner
|
||||||
User to chown to.
|
User to chown to.
|
||||||
|
|
||||||
|
@ -50,6 +53,18 @@ recursive
|
||||||
shallow
|
shallow
|
||||||
Sets --depth=1 and --shallow-submodules for cloning repositories with big history.
|
Sets --depth=1 and --shallow-submodules for cloning repositories with big history.
|
||||||
|
|
||||||
|
MESSAGES
|
||||||
|
--------
|
||||||
|
change <old_branch> -> <new_branch>
|
||||||
|
The directory tracks old_branch but should track new_branch, it will be changed
|
||||||
|
chown -R <owner>:<group>
|
||||||
|
Changed ownership
|
||||||
|
create
|
||||||
|
Freshly created the directory with the repository clone
|
||||||
|
remove
|
||||||
|
The directory with the repository exists, but state is absent, it will be removed
|
||||||
|
update
|
||||||
|
The repository tracks a branch that has been updated on the remote
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
--------
|
--------
|
||||||
|
|
0
cdist/conf/type/__git/parameter/default/onchange
Normal file
0
cdist/conf/type/__git/parameter/default/onchange
Normal file
|
@ -1,5 +1,6 @@
|
||||||
state
|
state
|
||||||
branch
|
branch
|
||||||
group
|
group
|
||||||
|
onchange
|
||||||
owner
|
owner
|
||||||
mode
|
mode
|
||||||
|
|
Loading…
Reference in a new issue