summaryrefslogtreecommitdiffstats
path: root/tools/test-hook.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:06:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:06:49 +0000
commit2fe34b6444502079dc0b84365ce82dbc92de308e (patch)
tree8fedcab52bbbc3db6c5aa909a88a7a7b81685018 /tools/test-hook.sh
parentInitial commit. (diff)
downloadansible-lint-2fe34b6444502079dc0b84365ce82dbc92de308e.tar.xz
ansible-lint-2fe34b6444502079dc0b84365ce82dbc92de308e.zip
Adding upstream version 6.17.2.upstream/6.17.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/test-hook.sh')
-rwxr-xr-xtools/test-hook.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/test-hook.sh b/tools/test-hook.sh
new file mode 100755
index 0000000..85d2d27
--- /dev/null
+++ b/tools/test-hook.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# This scripts checks if ansible-lint works as a hook as expected.
+SOURCE=${BASH_SOURCE[0]}
+while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
+ DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
+ SOURCE=$(readlink "$SOURCE")
+ [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
+done
+DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
+
+set -euo pipefail
+rm -rf .tox/x
+mkdir -p .tox/x
+cd .tox/x
+git init
+# we add a file to the repo to avoid error due to no file to to lint
+touch foo.yml
+git add foo.yml
+python3 -m pre_commit try-repo -v "${DIR}/.." ansible-lint