Skip to content

Commit

Permalink
rusty-hook: only run the checks needed for the files modified
Browse files Browse the repository at this point in the history
  • Loading branch information
BrewingWeasel committed Nov 17, 2023
1 parent a2cb9b2 commit 5a25acb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .rusty-hook.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[hooks]
pre-commit = "just check"
pre-commit = "just pre-commit"
post-commit = "echo commited!"

[logging]
Expand Down
22 changes: 20 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ lint:
format:
leptosfmt ./src-ui/src
cargo fmt
@# TODO: some sort of css formatting (prettier?)
# TODO: some sort of css formatting (prettier?)

# Fix code not passing pre-commit hook (uses --allow-dirty + --allow-staged on clippy)
force-fix: && format
Expand All @@ -23,7 +23,25 @@ fix: && format
test:
cargo test

check: test lint
rust-check: test lint

ci-check:
actionlint

check:
rust-check

pre-commit:
#!/usr/bin/env sh
newfiles=$(git status --porcelain | awk '{ print $2 }')
if (echo $newfiles | grep ".rs" ); then
just rust-check
fi
if (echo $newfiles | grep ".github" ); then
just ci-check
fi
# TODO: do this with other languages
# TODO: make this only do stuff for the specific rust directories modified
_install program command:
#!/usr/bin/env sh
Expand Down

0 comments on commit 5a25acb

Please sign in to comment.