summaryrefslogtreecommitdiff
path: root/scripts/pre-commit.sh
blob: 38894f40aebd534a01cb1ce7b2963570e9fda8c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

if git rev-parse --verify HEAD >/dev/null 2>&1
then
	base=HEAD
else
	# Initial commit: diff against an empty tree object
	base=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi

error=0

# Validate new/modified YAML project files
for i in $(git diff --cached --name-only --diff-filter=AM $base -- "*yaml" | grep -vF .schema.yaml)
do
	echo -n "Validating $i: "
	if ! scripts/validator "$i"
	then
		echo "ERROR: $i failed to validate"
		error=1
	fi
done

exit $error