diff options
author | Enrico Zini <enrico@enricozini.org> | 2022-06-22 11:03:24 +0200 |
---|---|---|
committer | Emilio Pozuelo Monfort <pochu@debian.org> | 2022-06-22 11:29:03 +0200 |
commit | fda71b541d09689c6f5a8ae7807321186d5f722f (patch) | |
tree | 1392f14693624d22fdee31cea8b000f470dceeb3 /bin | |
parent | 3f396f82becbb80a2a521a46c00875b04530cd68 (diff) |
Make setup-repo work with submodules
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/setup-repo | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/bin/setup-repo b/bin/setup-repo index ef7cf2c95b..1651534e14 100755 --- a/bin/setup-repo +++ b/bin/setup-repo @@ -4,8 +4,19 @@ set -e -SRC=../../conf/pre-commit -HOOK=.git/hooks/pre-commit +## variables +if [ -d .git ]; then + GIT_HOOKS_DIR=".git/hooks" +elif [ -e .git ]; then + GIT_DIR=$(awk '/gitdir:/ { print $2 }' .git) + GIT_HOOKS_DIR="$GIT_DIR/hooks" +else + echo "ERROR: Not in the top-level directory of the git repository." >&2 + exit 1 +fi + +SRC=$(realpath --relative-to "$GIT_HOOKS_DIR" conf/pre-commit) +HOOK="$GIT_HOOKS_DIR"/pre-commit install_pre_commit_hook() { if [ -L "${HOOK}" ] && [ "$(readlink ${HOOK})" = "${SRC}" ]; then |