From f5a6463c0a24e663bd126b2596dadf3afe60959a Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 16 Jan 2025 17:36:14 -0500 Subject: [PATCH 1/2] add fix_rust.sh script --- scripts/fix_rust.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 scripts/fix_rust.sh diff --git a/scripts/fix_rust.sh b/scripts/fix_rust.sh new file mode 100755 index 0000000000..ce10a4c6d3 --- /dev/null +++ b/scripts/fix_rust.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e # Exit immediately if a command exits with a non-zero status. + +# Function to check for git changes and commit if necessary. +commit_if_changes() { + if [ -n "$(git status --porcelain)" ]; then + echo "changes detected, committing..." + git commit --allow-empty -am "$1" + echo "commit created." + fi +} + +# Step 1: Run cargo check and commit changes to Cargo.lock if any. +cargo check --workspace +commit_if_changes "commit Cargo.lock" + +# Step 2: Run cargo clippy with fixes and commit changes if any. +cargo clippy --fix --workspace --all-features +commit_if_changes "cargo clippy" + +# Step 3: Run cargo fix and commit changes if any. +cargo fix --workspace --all-features --all-targets +commit_if_changes "cargo fix" + +# Step 4: Run cargo fmt and commit changes if any. +cargo fmt +commit_if_changes "cargo fmt" From 8482e2733ab4b536844c39fc9d24555a63c7857d Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 16 Jan 2025 18:16:27 -0500 Subject: [PATCH 2/2] remove --allow-empty --- scripts/fix_rust.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/fix_rust.sh b/scripts/fix_rust.sh index ce10a4c6d3..9d2af2904b 100755 --- a/scripts/fix_rust.sh +++ b/scripts/fix_rust.sh @@ -6,7 +6,7 @@ set -e # Exit immediately if a command exits with a non-zero status. commit_if_changes() { if [ -n "$(git status --porcelain)" ]; then echo "changes detected, committing..." - git commit --allow-empty -am "$1" + git commit -am "$1" echo "commit created." fi }