Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a pre-commit hook in Beckn core specification repository #401

Open
wants to merge 5 commits into
base: draft
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
After sufficient deliberation, these drafts may be published as a Protocol Standard.
8 changes: 8 additions & 0 deletions pre-commit-scripts/README.md
Original file line number Diff line number Diff line change
@@ -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'
30 changes: 30 additions & 0 deletions pre-commit-scripts/pre-commit
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions pre-commit-scripts/setup-precommit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
git config core.hooksPath pre-commit-scripts