mirror of
https://github.com/apple/container.git
synced 2026-08-24 10:05:43 -05:00
Make pre-commit hook installation and execution work in git worktrees (#1643)
- Closes #1641. - This PR replaces the existing hook pathname computation for `make pre-commit` with `git rev-parse --git-path hooks/...`, which resolves to the shared hooks directory in both the main checkout and any worktree.
This commit is contained in:
@@ -319,12 +319,13 @@ check-licenses:
|
||||
|
||||
.PHONY: pre-commit
|
||||
pre-commit:
|
||||
cp scripts/pre-commit.fmt .git/hooks
|
||||
touch .git/hooks/pre-commit
|
||||
cat .git/hooks/pre-commit | grep -v 'hooks/pre-commit\.fmt' > /tmp/pre-commit.new || true
|
||||
echo 'PRECOMMIT_NOFMT=$${PRECOMMIT_NOFMT} $$(git rev-parse --show-toplevel)/.git/hooks/pre-commit.fmt' >> /tmp/pre-commit.new
|
||||
mv /tmp/pre-commit.new .git/hooks/pre-commit
|
||||
chmod +x .git/hooks/pre-commit
|
||||
$(eval HOOKS_DIR := $(shell git rev-parse --git-path hooks))
|
||||
cp scripts/pre-commit.fmt $(HOOKS_DIR)/
|
||||
touch $(HOOKS_DIR)/pre-commit
|
||||
cat $(HOOKS_DIR)/pre-commit | grep -v 'hooks/pre-commit\.fmt' > /tmp/pre-commit.new || true
|
||||
echo 'PRECOMMIT_NOFMT=$${PRECOMMIT_NOFMT} $$(git rev-parse --git-path hooks/pre-commit.fmt)' >> /tmp/pre-commit.new
|
||||
mv /tmp/pre-commit.new $(HOOKS_DIR)/pre-commit
|
||||
chmod +x $(HOOKS_DIR)/pre-commit
|
||||
|
||||
.PHONY: serve-docs
|
||||
serve-docs:
|
||||
|
||||
Reference in New Issue
Block a user