git.delta.rocks / unique-network / refs/commits / 9a3d9a718439

difftreelog

Merge pull request #838 from UniqueNetwork/feature/pre-push-checks

Yaroslav Bolyukin2023-09-22parents: #f32d3e5 #cd77dae.patch.diff
in: master

4 files changed

modified.envrcdiffbeforeafterboth
--- a/.envrc
+++ b/.envrc
@@ -19,6 +19,10 @@
     fi
 }
 
+if ! diff .githooks/pre-commit .git/hooks/pre-commit  >/dev/null; then
+echo -e "${RED}Hooks are updated, run make git-hooks${RESET}"
+fi
+
 watch_file .baedeker/.bdk-env/discover.env
 if test -f .baedeker/.bdk-env/discover.env; then
     check_bdk baedeker
added.githooks/pre-commitdiffbeforeafterboth
after · .githooks/pre-commit
1#!/usr/bin/env bash2#3# Pre-push hook verifying that inappropriate code will not be pushed.45# Colors for the terminal output6RED='\033[0;31m'7GREEN='\033[0;32m'8NC='\033[0m' # No Color910echo "Starting cargo fmt.."11cargo fmt --check12FMT_EXIT="$?"1314# Check that prettier formatting rules are not violated.15if [[ "${FMT_EXIT}" = 0 ]]; then16    echo -e "${GREEN}cargo fmt succeded${NC}"17else18    echo -e "${RED}Commit error!${NC}"19    echo "Please format the code via 'cargo fmt', cannot commit unformatted code"20    exit 121fi2223STAGED_TEST_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".ts$\|.js$")2425if [[ "$STAGED_TEST_FILES" = "" ]]; then26  echo -e "${GREEN}eslint succeded${NC}"27  exit 028fi2930echo "Starting eslint.."31./tests/node_modules/.bin/eslint --max-warnings 0 ${STAGED_TEST_FILES[@]}32ESLINT_EXIT="$?"3334if [[ "${ESLINT_EXIT}" = 0 ]]; then35    echo -e "${GREEN}eslint succeded${NC}"36else37    echo -e "${RED}Commit error!${NC}"38    echo "Please format the code via 'yarn fix', cannot Commit unformatted code"39    exit 140fi4142exit $?
modifiedMakefilediffbeforeafterboth
--- a/Makefile
+++ b/Makefile
@@ -167,3 +167,13 @@
 .PHONY: clippy
 clippy:
 	cargo clippy --features=quartz-runtime,unique-runtime,try-runtime,runtime-benchmarks --tests
+
+.PHONY: git-hooks
+git-hooks:
+	cp .githooks/pre-commit .git/hooks/pre-commit
+
+.PHONY: init
+init:
+	make git-hooks
+	cd tests
+	yarn install
modifiedREADME.mddiffbeforeafterboth
--- a/README.md
+++ b/README.md
@@ -159,6 +159,11 @@
 cd tests && yarn eslint --ext .ts,.js src/
 ```
 
+### Enable checking of code style on commits
+```bash
+make git-hooks
+```
+
 
 ## Karura token transfer