Skip to content

Commit

Permalink
Change pre-commit and CI hook to reflect new formatting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
akoshelev committed Aug 11, 2023
1 parent 2ffce66 commit 885fdad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Check formatting
run: cargo fmt --all -- --check --config imports_granularity=Crate
run: cargo fmt --all -- --check --config "imports_granularity=Crate,group_imports=StdExternalCrate"

- name: Clippy
if: ${{ success() || failure() }}
Expand Down
8 changes: 5 additions & 3 deletions pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ stashfile=$(mktemp .pre-commit.stashXXXXXX)
trap 'set +e;git stash pop -q; rm -f "$stashfile"; restore_merge_files' EXIT
save_merge_files
git stash push -k -u -q -m "pre-commit stash"
if ! errors=($(cargo fmt -- --check --config imports_granularity=Crate -l)); then

fmtconfig="imports_granularity=Crate,group_imports=StdExternalCrate"
if ! errors=($(cargo fmt --all -- --check --config "$fmtconfig" -l)); then
echo "Formatting errors found."
echo "Run \`cargo fmt -- --config imports_granularity=Crate\` to fix the following files:"
echo "Run \`cargo fmt --all -- --config \"$fmtconfig\"\` to fix the following files:"
for err in "${errors[@]}"; do
echo " $err"
done
Expand Down Expand Up @@ -102,4 +104,4 @@ check "Sort benchmark" \

check "ipa-macros tests" \
pushd ipa-macros && cargo test --features="trybuild" && popd


0 comments on commit 885fdad

Please sign in to comment.