blob: bc7fb6e5554089e3bd5e510305b19a91deebc436 (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/bin/bash
set -e
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
for i in $(git diff --cached --name-only --diff-filter=AM $base -- "*yaml" | grep -vF .schema.yaml)
do
# Generate unique key if missing
if ! grep -q ^key: "$i"
then
key=$(uuid)
while grep -qrw "$key" .
do
key=$(uuid)
done
echo "Generated key $key for $i"
sed -i "/^team:/akey: $key" "$i"
git add "$i"
fi
# Validate new/modified YAML project files
echo -n "Validating $i: "
if ! scripts/validator "$i"
then
echo "ERROR: $i failed to validate"
error=1
fi
done
exit $error
|