Hooks
git-gamble provides his own custom git hooks to enhance the development workflow
These hooks can be used to perform specific actions before and after gambling
Before Gambling (pre-gamble)
The pre-gamble hook is executed before the actual gambling process begins
Sometimes, you want to have certain things imperatively done before gambling on the tests
What if something irrelevant was just missing and that forgetting this was not worth starting again ?
Examples :
- Formatting
- Linting
After Gambling (post-gamble)
The post-gamble hook is triggered after the gambling result is known
Sometimes, you want to do actions after the gamble only in some situations
Examples :
- Wrong gamble (
pass failorfail pass)- Suggest to take a break
- Good gamble (
pass passorfail fail)- Congratulate
- Failing tests (
fail fail)- Remember to not push on the main branch
- Passing tests (
pass pass)- Run acceptance tests to check the status of the Double Loop TDD / ATDD loop
- Suggest to push
- Push automatically
If you have more ideas, please share them by opening an issue
Hook Execution and Configuration
Custom hooks are called with arguments :
pre-gamble <GAMBLED>pre-gamblehook is executed with one argument<GAMBLED>
post-gamble <GAMBLED> <ACTUAL>post-gamblehook is executed with two arguments<GAMBLED>and<ACTUAL>
Where :
<GAMBLED>ispassorfail<ACTUAL>ispassorfail
Custom hooks of git-gamble are like any other client-side git hooks :
-
a hook is a file (
pre-gambleorpost-gamble) -
a hook must be in the
$GIT_DIR/hooks/folder- or in the folder configured by
git config core.hooksPath
- or in the folder configured by
-
a hook must be executable
-
to make it executable, execute the following command
chmod +x .git/hooks/*-gamble
-
-
will not be executed if any of these options are used :
--no-verify--dry-run
Hooks Execution Lifecycle
The following diagram shows when custom hooks are executed in relation to standard git hooks
Textual description of the hooks execution lifecycle
- User executes the command
git-gamble --passORgit-gamble --fail git-gambleexecutes the hookpre-gamble passORpre-gamble failgit-gambleexecutes the commandgit add --allgit-gambleexecutes the commandexec $GAMBLE_TEST_COMMAND- When gamble success
git-gambleexecutes the commandgit commitgitexecutes the hookpre-commitgitexecutes the hookprepare-commit-msg $GIT_DIR/COMMIT_EDITMSG messagegitexecutes the hookcommit-msg $GIT_DIR/COMMIT_EDITMSGgitexecutes the hookpost-commit- When gambling
failafter another gamblefailgitexecutes the hookpost-rewrite amend
git-gambleexecutes the hookpost-gamble pass passORpost-gamble fail passdepending on what the user gambled
- When gamble error
git-gambleexecutes the commandgit reset --hardgit-gambleexecutes the hookpost-gamble pass failORpost-gamble fail faildepending on what the user gambled