summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Michael Brummer <jan.brummer@tabos.org>2023-02-07 12:15:00 +0100
committerJan-Michael Brummer <jan.brummer@tabos.org>2023-03-27 16:31:58 +0200
commitbd9d58b9bdc7fc7ca9a7caa4b590d6c9f0b6fc06 (patch)
tree456f75e34d0535b61438ec2a418cf58fe67d114d
parent6b59dd19f667135482de2a70f8a219c35af0eaa7 (diff)
downloadlibproxy-git-bd9d58b9bdc7fc7ca9a7caa4b590d6c9f0b6fc06.tar.gz
Rework pre-commit hook installation (#52)
Ensure that it runs on all supported systems.
-rw-r--r--data/install-git-hook.sh9
-rw-r--r--meson.build6
2 files changed, 8 insertions, 7 deletions
diff --git a/data/install-git-hook.sh b/data/install-git-hook.sh
index 7fd5550..355867b 100644
--- a/data/install-git-hook.sh
+++ b/data/install-git-hook.sh
@@ -2,11 +2,10 @@
cd "$MESON_SOURCE_ROOT"
-[ -d .git ] || exit 0 # not a git repo
-[ ! -f .git/hooks/pre-commit ] || exit 0 # already installed
+[ -d .git ] || exit 2 # not a git repo
+[ ! -f .git/hooks/pre-commit ] || exit 2 # already installed
-echo "Copying pre commit hook"
cp data/pre-commit-hook .git/hooks/pre-commit
-echo "Copying helper"
cp data/canonicalize_filename.sh .git/hooks/canonicalize_filename.sh
-echo "Done" \ No newline at end of file
+chmod +x .git/hooks/pre-commit
+echo "Activated pre-commit hook" \ No newline at end of file
diff --git a/meson.build b/meson.build
index a7be8a7..4a17bfe 100644
--- a/meson.build
+++ b/meson.build
@@ -127,5 +127,7 @@ summary({
}, section: 'Build environment')
# Install pre-commit hook
-git_hook_installer = find_program('data/install-git-hook.sh')
-run_command(git_hook_installer) \ No newline at end of file
+hook = run_command(join_paths(meson.project_source_root(), 'data/install-git-hook.sh'), check: false)
+if hook.returncode() == 0
+ message(hook.stdout().strip())
+endif \ No newline at end of file