Skip to content

Commit

Permalink
Add new pre-push hook to run zk fmt check
Browse files Browse the repository at this point in the history
  • Loading branch information
alekseysidorov committed Nov 23, 2020
1 parent 8eac414 commit 55e2445
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
RED='\033[0;31m'
NC='\033[0m' # No Color

# Check that formatting rules are not violated.
if !(cargo fmt -- --check && zk fmt --check); then
# Check that Rust formatting rules are not violated.
if ! cargo fmt -- --check; then
echo -e "${RED}Commit error!${NC}"
echo "Please format the code via 'cargo fmt', cannot commit unformatted code"
exit 1
Expand Down
14 changes: 14 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
#
# Pre-push hook verifying that inappropriate code will not be pushed.

# Colors for the terminal output
RED='\033[0;31m'
NC='\033[0m' # No Color

# Check that prettier formatting rules are not violated.
if ! zk fmt --check; then
echo -e "${RED}Commit error!${NC}"
echo "Please format the code via 'zk fmt', cannot push unformatted code"
exit 1
fi
7 changes: 4 additions & 3 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ zk down # Shut down `geth` and `postgres` containers

## Committing changes

`zksync` uses pre-commit git hooks for basic code integrity checks. Hooks are set up automatically within the workspace
initialization process. These hooks will not allow to commit the code which does not pass several checks.
`zksync` uses pre-commit and pre-push git hooks for basic code integrity checks. Hooks are set up automatically within
the workspace initialization process. These hooks will not allow to commit the code which does not pass several checks.

Currently the following criteria are checked:

- Code should always be formatted via `cargo fmt`.
- Rust code should always be formatted via `cargo fmt`.
- Other code should always be formatted via `zk fmt`.
- Dummy Prover should not be staged for commit (see below for the explanation).

## Using Dummy Prover
Expand Down

0 comments on commit 55e2445

Please sign in to comment.