Skip to content

Commit

Permalink
[CI] Fix the git hook is invalid if the project location changed (ray…
Browse files Browse the repository at this point in the history
…-project#41441)

In the ray project, we used the `setup_hooks.sh` to create the symbolic links to the relative hook script and these links used the absolute path, if the project location changed will cause can't find the real files.

Recommend to replace with the relative path.

Signed-off-by: Wanqiang Ji <me@jiwq.cn>
Co-authored-by: Lonnie Liu <95255098+aslonnie@users.noreply.github.com>
  • Loading branch information
jiwq and aslonnie authored Dec 8, 2023
1 parent 9ea2e8b commit b845a63
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions setup_hooks.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#!/bin/sh
chmod +x "$PWD"/ci/lint/pre-push
ln -s "$PWD"/ci/lint/pre-push "$PWD"/.git/hooks/pre-push
ln -s "$PWD"/ci/lint/prepare-commit-msg "$PWD"/.git/hooks/prepare-commit-msg
set -eu

# This stops git rev-parse from failing if we run this from the .git directory
builtin cd "$(dirname "${BASH_SOURCE:-$0}")"

ROOT="$(git rev-parse --show-toplevel)"
builtin cd "${ROOT}"

# If we change the lint location we should modify the path of lint relative .git
RELATIVE_PATH="../../ci/lint"

ln -sf "${RELATIVE_PATH}/pre-push" "${ROOT}/.git/hooks/pre-push"
ln -sf "${RELATIVE_PATH}/prepare-commit-msg" "${ROOT}/.git/hooks/prepare-commit-msg"

0 comments on commit b845a63

Please sign in to comment.