From f637cca528ea6b34bf47c43f076d832c814c338c Mon Sep 17 00:00:00 2001 From: Xuu Date: Wed, 25 Oct 2017 20:12:55 +0000 Subject: [PATCH 1/5] Update 'README.md' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 518c175d0..cab45a9b0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Tips for a successful Pull Request 1. Squash your commits -- Keep the changes simple to read. -2. Run the schema check -- Make sure the changes are valid! +2. Run the schema check -- Make sure the changes are valid! Run `./check-my-stuff YOUROWN-MNT` 3. Sign your commit -- Makes it easier to verify. 4. Bonus: add your pgp fingerprint to your MNT `auth: pgp-fingerprint ` [[See XUU-MNT example](data/mntner/XUU-MNT)] 3. ??? From d82a359e40459c189c7058e2bb178c7220ab5066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-R=C3=A9my=20Buchs?= Date: Wed, 25 Oct 2017 22:23:52 +0200 Subject: [PATCH 2/5] Add script to install pre-commit hook --- install-commit-hook | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 install-commit-hook diff --git a/install-commit-hook b/install-commit-hook new file mode 100755 index 000000000..be6525396 --- /dev/null +++ b/install-commit-hook @@ -0,0 +1,21 @@ +#!/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 </dev/null | grep -v PASS 1>/dev/null 2>&1 && { echo "Schema validation failed, please check above!" 1>&2; exit 1; } +EOF +chmod +x .git/hooks/pre-commit + From 4f95aaa7b0876ff083c68d0c215de95c4b025274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-R=C3=A9my=20Buchs?= Date: Wed, 25 Oct 2017 22:45:11 +0200 Subject: [PATCH 3/5] Fix shellcheck errors and warning on check-my-stuff --- check-my-stuff | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/check-my-stuff b/check-my-stuff index 64680c209..781037139 100755 --- a/check-my-stuff +++ b/check-my-stuff @@ -6,8 +6,8 @@ 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 +utils/schema-check/dn42-schema.py scan data/ -m "$1" From bf4d2ff39677b80072456b5d6fe9472f32d34729 Mon Sep 17 00:00:00 2001 From: xuu Date: Wed, 25 Oct 2017 15:23:34 -0600 Subject: [PATCH 4/5] update jrb0001's commit hook --- check-my-stuff | 3 ++- install-commit-hook | 7 +++---- utils/schema-check/dn42-schema.py | 13 ++++++++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/check-my-stuff b/check-my-stuff index 781037139..d5875b708 100755 --- a/check-my-stuff +++ b/check-my-stuff @@ -10,4 +10,5 @@ BASE="$(realpath "$0")" BASE="$(dirname "$BASE")" cd "$BASE" || exit 1 -utils/schema-check/dn42-schema.py scan data/ -m "$1" +utils/schema-check/dn42-schema.py scan data/ -m "$1" || ( echo "Schema validation failed, please check above!" ; exit 1 ) + diff --git a/install-commit-hook b/install-commit-hook index be6525396..63a3d965c 100755 --- a/install-commit-hook +++ b/install-commit-hook @@ -10,12 +10,11 @@ BASE="$(realpath "$0")" BASE="$(dirname "$BASE")" cd "$BASE" || exit 1 -cat >> .git/hooks/pre-commit < .git/hooks/pre-commit </dev/null | grep -v PASS 1>/dev/null 2>&1 && { echo "Schema validation failed, please check above!" 1>&2; exit 1; } +./check-my-stuff "$1" || exit 1 + EOF chmod +x .git/hooks/pre-commit diff --git a/utils/schema-check/dn42-schema.py b/utils/schema-check/dn42-schema.py index deaf3f22d..430c92f3b 100755 --- a/utils/schema-check/dn42-schema.py +++ b/utils/schema-check/dn42-schema.py @@ -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) From 151e0974f149bd49d5368971b8ab34fb4b00b355 Mon Sep 17 00:00:00 2001 From: Xuu Date: Wed, 25 Oct 2017 21:30:40 +0000 Subject: [PATCH 5/5] Update 'README.md' --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cab45a9b0..2d0352d53 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # Tips for a successful Pull Request 1. Squash your commits -- Keep the changes simple to read. 2. Run the schema check -- Make sure the changes are valid! Run `./check-my-stuff YOUROWN-MNT` -3. Sign your commit -- Makes it easier to verify. -4. Bonus: add your pgp fingerprint to your MNT `auth: pgp-fingerprint ` [[See XUU-MNT example](data/mntner/XUU-MNT)] -3. ??? -4. Profit! +3. BONUS: install the commit hook! Run `./install-commit-hook YOUROWN-MNT` +4. Sign your commit -- Makes it easier to verify. +5. Bonus: add your pgp fingerprint to your MNT `auth: pgp-fingerprint ` [[See XUU-MNT example](data/mntner/XUU-MNT)] +6. ??? +7. Profit!