I am looking into git hooks to automate the process of setting up custom config paths
when developing and then resetting the paths when pushing back to upstream.
Use-case: doom-nvim
The default of doom-nvim is for user to install to ~/.config/nvim but since I/we
are using Cheovim I do believe that most of us are using a custom installer location.
Therefor, it would be nice to setup post-checkout and pre-push hooks that take care
of modifying the doom root path so that one doesn't need to always update these paths
manually when switching between local dev/personal branch and a, (in my case), temporary
fetch of upstream development in order to apply patch/rebase/cherry-pick commits etc.
This could then be a recommendation in contribution docs to add these two hooks should
one like to.
Note
Personally I have never used hooks before so I am posting my research here. ;)
``` bash
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
#
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).
remote="$1"
url="$2"
zero=$(git hash-object --stdin &2 "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
exit 0
```
I am looking into git hooks to automate the process of setting up custom config paths when developing and then resetting the paths when pushing back to upstream.
Use-case: doom-nvim
The default of doom-nvim is for user to install to ~/.config/nvim but since I/we are using Cheovim I do believe that most of us are using a custom installer location. Therefor, it would be nice to setup
post-checkout
andpre-push
hooks that take care of modifying the doom root path so that one doesn't need to always update these paths manually when switching between local dev/personal branch and a, (in my case), temporary fetch of upstream development in order to apply patch/rebase/cherry-pick commits etc.This could then be a recommendation in contribution docs to add these two hooks should one like to.
Note
Personally I have never used hooks before so I am posting my research here. ;)
resources
Below are interesting links that I have found.
Example 1: post-checkout
do stuff when checking out branch locally
example source
Example:
Example 2: pre-push
taken from
.git/hooks/pre-push.sample