Merge branch 'commit-hook' of dn42/registry into master

This commit is contained in:
Xuu 2017-10-25 21:25:39 +00:00 committed by dn42 Git Service
commit 9f1015f4c5
3 changed files with 35 additions and 7 deletions

View file

@ -6,8 +6,9 @@ if [ $# -eq 0 ]
exit
fi
BASE=$(realpath $0)
BASE=$(dirname $BASE)
cd $BASE
BASE="$(realpath "$0")"
BASE="$(dirname "$BASE")"
cd "$BASE" || exit 1
utils/schema-check/dn42-schema.py scan data/ -m "$1" || ( echo "Schema validation failed, please check above!" ; exit 1 )
utils/schema-check/dn42-schema.py scan data/ -m $1

20
install-commit-hook Executable file
View file

@ -0,0 +1,20 @@
#!/bin/sh
if [ $# -eq 0 ]
then
echo "Usage: $0 YOUR-MNT"
exit
fi
BASE="$(realpath "$0")"
BASE="$(dirname "$BASE")"
cd "$BASE" || exit 1
cat > .git/hooks/pre-commit <<EOF
#!/bin/sh
./check-my-stuff "$1" || exit 1
EOF
chmod +x .git/hooks/pre-commit

View file

@ -266,8 +266,10 @@ def __scan_index(idx, schemas, mntner):
continue
c = FileDOM(v[0])
ck = s.check_file(c, idx.keys())
if not ck:
ok = False
if ck == "INFO" and ok != "FAIL":
ok = ck
if ck == "FAIL":
ok = ck
return ok
@ -397,5 +399,10 @@ if __name__ == '__main__':
elif args["command"] == "scan":
import time
log.notice("## Scan Started at %s" %(time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())))
scan_files(args["path"], args["use_mntner"])
ck = scan_files(args["path"], args["use_mntner"])
log.notice("## Scan Completed at %s" %(time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())))
if ck == "INFO":
sys.exit(2)
elif ck == "FAIL":
sys.exit(1)