amaechler commented on code in PR #20477:
URL: https://github.com/apache/druid/pull/20477#discussion_r4175962385


##########
hooks/install-hooks.sh:
##########
@@ -32,10 +32,11 @@ if [ $# != 1 ]
 fi
 
 DRUID_ROOT=$1
+GIT_HOOKS_DIR="$(git -C "${DRUID_ROOT}" rev-parse --path-format=absolute 
--git-common-dir)/hooks"

Review Comment:
   Reverting this. Following `core.hooksPath` means a global hooks path gets 
Druid's hooks, so pushes from unrelated repos run `checkstyle-check`, and 
`core.hooksPath=hooks` points the uninstaller at the tracked sources (the P1 
below). Both scripts go back to `--git-common-dir`, which handles linked 
worktrees. If you use `core.hooksPath`, you can now point it at the tracked 
hooks with `git config core.hooksPath hooks`; they find their helpers through 
`$0` and need no install step.



##########
hooks/uninstall-hooks.sh:
##########
@@ -19,19 +19,14 @@
 # under the License.
 #
 
-if [ $# != 1 ]
-  then
-    echo 'usage: program {$DRUID_ROOT}'
-    exit 1
-fi
-
-DRUID_ROOT=$1
+DRUID_ROOT="${1:-$(dirname "$0")/..}"
+GIT_HOOKS_DIR="$(git -C "${DRUID_ROOT}" rev-parse --path-format=absolute 
--git-path hooks)"
 
 # This script does not remove .git/hooks/pre-commit, .git/hooks/pre-push, or 
any other git hook scripts
 # because those files may have user-custom hooks.
 # Instead, we remove only the files and directories that we are sure it is 
safe to remove.
-rm -f ${DRUID_ROOT}/.git/hooks/run-all-in-dir.py
-rm -rf ${DRUID_ROOT}/.git/hooks/pre-commits
-rm -rf ${DRUID_ROOT}/.git/hooks/pre-pushes
+rm -f "${GIT_HOOKS_DIR}/run-all-in-dir.py"
+rm -rf "${GIT_HOOKS_DIR}/pre-commits"

Review Comment:
   Agreed, this came from following `core.hooksPath`. Reverted to 
`--git-common-dir`, so both scripts only touch this repo's `.git/hooks`, as 
before this PR.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to