Skip to content

Commit 92327f0

Browse files
authored
make the rust checks work if code is in a sub directory (#5)
1 parent f3a26e1 commit 92327f0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pre-commit-hooks/rust-fmt.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
# Exit immediately if a command exits with a non-zero status
44
set -e
55

6+
# Get the directory to run cargo fmt in, default to current directory
7+
RUST_DIR=${1:-.}
8+
69
# Function to format rust code
710
run_cargo_fmt() {
811
echo "Executing 'cargo fmt'"
12+
cd "$RUST_DIR"
913
cargo fmt
1014
}
1115

pre-commit-hooks/rust-lint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
# Exit immediately if a command exits with a non-zero status.
44
set -e
55

6+
# Get the directory to run cargo fmt in, default to current directory
7+
RUST_DIR=${1:-.}
8+
69
# Function to run linters on the rust project
710
run_linter() {
811
echo "Executing clippy"
912

1013
# Run the linter and capture the exit status
1114
set +e
15+
cd "$RUST_DIR"
1216
cargo clippy -- -D warnings
1317
local linting_result=$?
1418
set -e

0 commit comments

Comments
 (0)