diff --git a/docs/README.md b/docs/README.md index e05935f3..4172f16a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,4 +2,4 @@ These files contain specifications that have been selected from the proposals submitted to the beckn protocol specifications. The are currently under review by different working groups in the various categories supported beckn protocol governance. -After sufficient deliberation, these drafts may be published as a Protocol Standard. \ No newline at end of file +After sufficient deliberation, these drafts may be published as a Protocol Standard. \ No newline at end of file diff --git a/pre-commit-scripts/README.md b/pre-commit-scripts/README.md new file mode 100644 index 00000000..9a3e678e --- /dev/null +++ b/pre-commit-scripts/README.md @@ -0,0 +1,8 @@ +## Follow the below steps to setup the pre-commit hook on your system. + +1. Install node if not allready installed. +2. Install 'beckn-spec-validator' package if not allready installed. use command, 'npm install -g beckn-spec-validator' +3. cd to the 'pre-commit-scripts' directory +4. Make sure that the ;setup-precommit.sh' is executable. if not, run command 'chmod +x setup-precommit.sh' to make it executable. +5. Make sure that the 'pre-commit' is executable. if not, run command 'chmod +x pre-commit' to make it executable. +5. run the shell script to setup pre-commit hook. './setup-precommit' \ No newline at end of file diff --git a/pre-commit-scripts/pre-commit b/pre-commit-scripts/pre-commit new file mode 100755 index 00000000..96133d87 --- /dev/null +++ b/pre-commit-scripts/pre-commit @@ -0,0 +1,30 @@ +#!/bin/sh + +# pre-commit.sample + +run_verify_command () { + command=$1 + if + eval $1 + then + return 0 + else + echo "*****Spec validation has failed for following command******" + echo "$command" + echo "*****Commit has been aborted******" + git stash pop -q + exit 1 + fi +} + + + +git stash -q --keep-index + +# Add one line per file that needs to be checked +run_verify_command "beckn-spec-validator -b api/meta/build/meta.yaml -v false" +run_verify_command "beckn-spec-validator -b api/transaction/build/transaction.yaml -v false" +run_verify_command "beckn-spec-validator -b api/registry/build/registry.yaml -v false" + +git stash pop -q +exit 0 diff --git a/pre-commit-scripts/setup-precommit.sh b/pre-commit-scripts/setup-precommit.sh new file mode 100755 index 00000000..a747b04c --- /dev/null +++ b/pre-commit-scripts/setup-precommit.sh @@ -0,0 +1,2 @@ +#!/bin/sh +git config core.hooksPath pre-commit-scripts