Merge pull request #70 from cweagans/hooks

Dropping changes to `yadm.md` and `CONTRIBUTORS`. These are built
programmatically during releases.
This commit is contained in:
Tim Byrne 2017-07-03 16:24:13 -05:00
commit df21cd2cb8
No known key found for this signature in database
GPG Key ID: 14DB4FC2465A4B12
2 changed files with 29 additions and 0 deletions

14
yadm
View File

@ -97,10 +97,14 @@ function main() {
shift
done
[ ! -d "$YADM_WORK" ] && error_out "Work tree does not exist: [$YADM_WORK]"
invoke_hook "pre_$YADM_COMMAND"
$YADM_COMMAND "${YADM_ARGS[@]}"
invoke_hook "post_$YADM_COMMAND"
else
#; any other commands are simply passed through to git
invoke_hook "pre_$1"
git_command "$@"
invoke_hook "post_$1"
retval="$?"
fi
@ -853,6 +857,16 @@ function error_out() {
}
#: ****** Hook handler ******S
function invoke_hook() {
hook_name=$1
if [[ -x "$YADM_DIR/hooks/$hook_name.sh" ]] ; then
debug "invoking hook: $hook_name"
$YADM_DIR/hooks/$hook_name.sh
fi
}
#; ****** Auto Functions ******
function auto_alt() {

15
yadm.1
View File

@ -400,6 +400,21 @@ Override the HOSTNAME for the purpose of symlinking alternate files.
.TP
.B local.user
Override the USER for the purpose of symlinking alternate files.
.SH HOOKS
.B yadm
has the capability to execute scripts before or after any operation that
.B yadm
can perform. To utilize this functionality, create a directory to store the hook
scripts at
.BR $HOME/.yadm/hooks.
Then, create scripts inside this directory for whatever operation you want to
hook into. For instance, if you'd like a script to run after
.B yadm pull,
your hook script should be executable and located at
.BR $HOME/.yadm/hooks/post_pull.sh.
Any of the
.B yadm
subcommands can utilize this functionality.
.SH ALTERNATES
When managing a set of files across different systems, it can be useful to have
an automated way of choosing an alternate version of a file for a different