diff options
author | Kate Ward <kate.ward@forestent.com> | 2020-04-10 15:17:35 +0200 |
---|---|---|
committer | Kate Ward <kate.ward@forestent.com> | 2020-04-10 15:17:35 +0200 |
commit | 2523169c1a297331a400e548edec32fa891c1bed (patch) | |
tree | 3b6337f73d44cbfaeb4be41da066256726a105e2 /init_githooks.sh | |
parent | 77a6d9e2425071609c843751f83b2eaca5c9a06a (diff) | |
download | shflags-2523169c1a297331a400e548edec32fa891c1bed.tar.gz |
Fixes to hooks.
Diffstat (limited to 'init_githooks.sh')
-rwxr-xr-x | init_githooks.sh | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/init_githooks.sh b/init_githooks.sh index d5a7f50..19a380f 100755 --- a/init_githooks.sh +++ b/init_githooks.sh @@ -3,13 +3,18 @@ # Initialize the local git hooks this repository. # https://git-scm.com/docs/githooks -topLevel=$(git rev-parse --show-toplevel) && cd "${topLevel}" +topLevel=$(git rev-parse --show-toplevel) +if ! cd "${topLevel}"; then + echo "filed to cd into topLevel directory '${topLevel}'" + exit 1 +fi + hooksDir="${topLevel}/.githooks" -hooksPath=$(git config core.hooksPath) -if [ $? -ne 0 ]; then - hooksPath="${topLevel}/.git/hooks" +if ! hooksPath=$(git config core.hooksPath); then + hooksPath="${topLevel}/.git/hooks" fi +src="${hooksDir}/generic" echo "linking hooks..." for hook in \ applypatch-msg \ @@ -36,11 +41,7 @@ for hook in \ p4-pre-submit \ post-index-change do - src="${hooksDir}/${hook}" + echo "- ${hook}" dest="${hooksPath}/${hook}" - - [ -x "${src}" ] || continue - - echo "- ${hook}" - ln -sf "${src}" "${dest}" + ln -sf "${src}" "${dest}" done |