Skip to content

Commit

Permalink
feat(common): Support git worktree when configuring local hooks
Browse files Browse the repository at this point in the history
When using worktrees in git the hooks directory is under the main
worktree directory. `$ROOT/.git` might be a text file instead of a
folder. `git rev-parse` will return the correct location in all
cases.
  • Loading branch information
ermshiperete committed Feb 24, 2020
1 parent c850fc2 commit 49005fb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions configure-repo.sh
Expand Up @@ -6,7 +6,6 @@
# Run this script once to configure your system to work with our Git workflow.
#

ROOT=$(git rev-parse --show-toplevel)
if [[ -n "$WINDIR" ]]; then
# https://stackoverflow.com/a/39160850/1836776
SCRIPT_DIR=$(cmd //C cd)
Expand All @@ -32,8 +31,9 @@ case $1 in
cmd //C "mklink $WinPWD\\.git\\hooks\\commit-msg $WinPWD\\resources\\git-hooks\\commit-msg"
cmd //C "mklink $WinPWD\\.git\\hooks\\prepare-commit-msg $WinPWD\\resources\\git-hooks\\prepare-commit-msg"
else
ln -sf "$SCRIPT_DIR/resources/git-hooks/commit-msg" "$ROOT/.git/hooks/commit-msg"
ln -sf "$SCRIPT_DIR/resources/git-hooks/prepare-commit-msg" "$ROOT/.git/hooks/prepare-commit-msg"
HOOKSDIR=$(git rev-parse --git-path hooks)
ln -sf "$SCRIPT_DIR/resources/git-hooks/commit-msg" "$HOOKSDIR/commit-msg"
ln -sf "$SCRIPT_DIR/resources/git-hooks/prepare-commit-msg" "$HOOKSDIR/prepare-commit-msg"
fi
;;
*)
Expand Down

0 comments on commit 49005fb

Please sign in to comment.