BLOG-145 Add pre-commit hooks #147

Merged
squid merged 5 commits from BLOG-145_add_pre_commit_hooks into main 2025-10-15 13:11:26 +08:00
4 changed files with 36 additions and 0 deletions
Showing only changes of commit 2df96e966d - Show all commits

18
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,18 @@
repos:
- repo: local
hooks:
- id: sqlx-prepare
name: sqlx prepare
language: script
entry: ./script/sqlx-prepare.sh
pass_filenames: false
- id: backend-check
name: backend check
language: system
entry: ./script/backend-check.sh
pass_filenames: false
- id: frontend-lint
name: frontend lint
language: system
entry: ./script/frontend-lint.sh
pass_filenames: false

6
script/backend-check.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
cd "$SCRIPT_DIR/../backend"
cargo check

6
script/frontend-lint.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
cd "$SCRIPT_DIR/../frontend"
pnpm lint

6
script/sqlx-prepare.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
cd "$SCRIPT_DIR/../backend"
cargo sqlx prepare --workspace