From 2fe34b6444502079dc0b84365ce82dbc92de308e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 14:06:49 +0200 Subject: Adding upstream version 6.17.2. Signed-off-by: Daniel Baumann --- tools/test-hook.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 tools/test-hook.sh (limited to 'tools/test-hook.sh') 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 -- cgit v1.2.3