Add better facility to resume / skip hooks #15

Open
avar opened this Issue Jun 1, 2012 · 2 comments

Projects

None yet

4 participants

Owner
avar commented Jun 1, 2012

We're increasingly reliant on hooks but our top-level command-line facility to interact with them pre-dates the phase hook support. We just have a --skip_hooks option which skips the run of all hooks. Things that we'd also like, in no particular order:

Sequencing support, the ability to continue after we fail after having run n/x hooks

Say we're running 2x pre-sync hooks and the sync hook fails, currently you have to re-run the path of the sync hook, but you have no idea if there were any post-sync hooks or anything else that needs to run.

Whenever we have a sequence of hooks we're running we should write that sequence to .git/deploy/sequencer, then you could do git-deploy --continue, git-deploy --abort etc. See ./Documentation/sequencer.txt in git.git for generic support for this (which we may or may not be able to use).

Continuing would try to re-run the failing hook (e.g. a broken sync hook), you could run that in a loop until it worked, and it would make sure to run the remaining hooks (if any), and finish appropriately.

Ability to skip specific hooks and to run new hooks

Now that we have phase hooks maybe this should be something like this:

# like --skip_hooks now, we could alias that to this:
--skip-hook=*
 # skip all log hooks
 --skip-hook=log.*
 # skip several types of hooks
 --skip-hook=sync.* --skip-hook=log.*
 # skip a specific hook
 --skip-hook=log.*jabber*
 # or just reply on it matching against the right thing out of all the hooks
 --skip-hook=*jabber*

While we're at it we could also include --add-hook, if we did that we could completely emulate the current hook support with command-line switches:

git-deploy --add-hook=start./some/path/000.start.pl start

Or something like that.

vexxor commented Jun 1, 2012

One of the things that comes to my mind when skiping or adding hooks is also a mechanism like the one used in git's interactive rebase.

So populate a file with all the hooks that are supposed to be run, load it into $EDITOR, and allow the user to comment out (or other things we think of) specific lines (hooks). Saving and quitting the $EDITOR would continue the process and use only the hooks chosen.

something like:

git-deploy --interactive-hooks start

I really like the sequencing approach, so if we were to employ something similar to what I proposed above, we would have to persist the chosen hooks so git-deploy --continue would't run hooks the user commented out before the process was interrupted.

Kalyse commented Dec 23, 2012

This would be quite useful, in the end I resorted to having something like this as my hook file.

This makes it a little more interactive and I can decide at runtime if I want to skip the hook or not.

#!/bin/bash
echo "=============="
echo "# Do you want to do a fresh build of Dojo and Static Assets?"
echo "=============="
echo "";
read -n1 -p  "(y/n)?"
[[ $REPLY = [yY] ]] && perl /var/www/site.com/bin/scripts/hooks/apps/common/git-build-static.pl
echo "";
@bucciarati bucciarati was assigned Feb 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment