Skip to content

Commit 55410a3

Browse files
authored
Merge pull request #1165 from opentensor/sam-add-fix-rust-script
add fix_rust.sh script
2 parents 5bd1e8c + 8482e27 commit 55410a3

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

scripts/fix_rust.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
set -e # Exit immediately if a command exits with a non-zero status.
4+
5+
# Function to check for git changes and commit if necessary.
6+
commit_if_changes() {
7+
if [ -n "$(git status --porcelain)" ]; then
8+
echo "changes detected, committing..."
9+
git commit -am "$1"
10+
echo "commit created."
11+
fi
12+
}
13+
14+
# Step 1: Run cargo check and commit changes to Cargo.lock if any.
15+
cargo check --workspace
16+
commit_if_changes "commit Cargo.lock"
17+
18+
# Step 2: Run cargo clippy with fixes and commit changes if any.
19+
cargo clippy --fix --workspace --all-features
20+
commit_if_changes "cargo clippy"
21+
22+
# Step 3: Run cargo fix and commit changes if any.
23+
cargo fix --workspace --all-features --all-targets
24+
commit_if_changes "cargo fix"
25+
26+
# Step 4: Run cargo fmt and commit changes if any.
27+
cargo fmt
28+
commit_if_changes "cargo fmt"

0 commit comments

Comments
 (0)