Skip to content

Commit ddd9fe3

Browse files
batpigandmekgryte
andauthored
build: fix resolve cache path in worktrees and submodules
PR-URL: #11501 Closes: #11500 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent d03f7d8 commit ddd9fe3

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

tools/git/hooks/commit-msg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ skip_lint="${SKIP_LINT_COMMIT}"
3333
# Get the path to a file containing the commit message:
3434
commit_message="$1"
3535

36-
# Determine root directory:
37-
root=$(git rev-parse --show-toplevel)
36+
# Resolve the location of the Git directory:
37+
git_dir=$(git rev-parse --absolute-git-dir)
3838

3939
# Define the path to a report generated during the pre-commit hook:
40-
pre_commit_report="${root}/.git/hooks-cache/pre_commit_report.yml"
40+
pre_commit_report="${git_dir}/hooks-cache/pre_commit_report.yml"
4141

4242

4343
# FUNCTIONS #

tools/git/hooks/pre-commit

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ skip_editorconfig="${SKIP_LINT_EDITORCONFIG}"
5050
# Determine root directory:
5151
root=$(git rev-parse --show-toplevel)
5252

53+
# Resolve the location of the Git directory:
54+
git_dir=$(git rev-parse --absolute-git-dir)
55+
5356
# Define the path to a utility for linting filenames:
5457
lint_filenames="${root}/lib/node_modules/@stdlib/_tools/lint/filenames/bin/cli"
5558

@@ -81,7 +84,7 @@ cppcheck_tests_fixtures_suppressions_list="${root}/etc/cppcheck/suppressions.tes
8184
cppcheck_benchmarks_suppressions_list="${root}/etc/cppcheck/suppressions.benchmarks.txt"
8285

8386
# Define the path to a directory for caching hook results:
84-
cache_dir="${root}/.git/hooks-cache"
87+
cache_dir="${git_dir}/hooks-cache"
8588

8689
# Define the path to a file for storing hook results:
8790
cache_file="${cache_dir}/pre_commit_report.yml"

tools/git/hooks/pre-push

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ GIT_CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
5959
# Determine root directory:
6060
root=$(git rev-parse --show-toplevel)
6161

62+
# Resolve the location of the Git directory:
63+
git_dir=$(git rev-parse --absolute-git-dir)
64+
6265
# Define the path to a directory for caching hook results:
63-
cache_dir="${root}/.git/hooks-cache"
66+
cache_dir="${git_dir}/hooks-cache"
6467

6568
# Define the path to a file for storing hook results:
6669
cache_file="${cache_dir}/pre_push_report.yml"

0 commit comments

Comments
 (0)