Skip to content

Commit

Permalink
make the rust checks work if code is in a sub directory (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
tateexon authored Oct 3, 2024
1 parent f3a26e1 commit 92327f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pre-commit-hooks/rust-fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
# Exit immediately if a command exits with a non-zero status
set -e

# Get the directory to run cargo fmt in, default to current directory
RUST_DIR=${1:-.}

# Function to format rust code
run_cargo_fmt() {
echo "Executing 'cargo fmt'"
cd "$RUST_DIR"
cargo fmt
}

Expand Down
4 changes: 4 additions & 0 deletions pre-commit-hooks/rust-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
# Exit immediately if a command exits with a non-zero status.
set -e

# Get the directory to run cargo fmt in, default to current directory
RUST_DIR=${1:-.}

# Function to run linters on the rust project
run_linter() {
echo "Executing clippy"

# Run the linter and capture the exit status
set +e
cd "$RUST_DIR"
cargo clippy -- -D warnings
local linting_result=$?
set -e
Expand Down

0 comments on commit 92327f0

Please sign in to comment.