From 5256afe7ac743e5ae36ff8b3974648da2026c770 Mon Sep 17 00:00:00 2001 From: core Date: Mon, 27 Nov 2023 13:40:38 -0500 Subject: [PATCH] fix the new hooks --- .git-hooks/pre-commit | 46 ++++++++-------------------------- server/src/component.rs | 4 ++- starkingdoms-client/index.html | 7 +++--- 3 files changed, 18 insertions(+), 39 deletions(-) diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index d9512bf7c4acacd90ab93e16d90b1dca3ae07480..41735acb5a17c1f55bb18e5aad13430e72475941 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -1,38 +1,14 @@ #!/bin/bash - echo "Checking your formatting..." - -HAS_ISSUES=0 - -for file in $(git diff --name-only --staged); do - FMT_RESULT="$(rustfmt --edition 2021 --skip-children --force --write-mode diff $file 2>/dev/null || true)" - if [ "$FMT_RESULT" != "" ]; then - echo -n "$file (rustfmt)" - HAS_ISSUES=1 - fi -done - -FIRST_FILE=1 -cd starkingdoms-client - -for file in $(git diff --name-only --staged); do - if [ $file == starkingdoms-client* ]; then - FMT_RESULT="$(yarn prettier $file --check 2>&1 > /dev/null || true)" - if [ "$FMT_RESULT" != "" ]; then - if [ $FIRST_FILE -eq 0 ]; then - echo "cd starkingdoms-client" - fi - echo -n "yarn prettier $file --write" - HAS_ISSUES=1 - FIRST_FILE=0 - fi - fi -done - -if [ $HAS_ISSUES -eq 0 ]; then - echo "Everything looks good! Proceeding with commit." - exit 0 +rustfmt server/src/*.rs --edition 2021 --check +if [ $? -ne 0 ]; then + echo "Uh oh, looks like your formatting is off! Run 'rustfmt server/src/*.rs --edition 2021' to fix it." + exit 1 fi - -echo "!! Some files have formatting issues! Run all of the above commands, and then attempt another commit." -exit 1 +cd starkingdoms-client && yarn prettier . --check +if [ $? -ne 0 ]; then + echo "Uh oh, looks like your formatting is off! Run 'cd starkingdoms-client && yarn prettier . --write' to fix it." + exit 1 +fi +echo "Everything looks good! Proceeding with commit..." +exit 0 diff --git a/server/src/component.rs b/server/src/component.rs index a0391186afbaaea29158a020c8aadafdb6ccc6ae..79ae11d40ff17c7f6f822b57eea923c92cfce95c 100644 --- a/server/src/component.rs +++ b/server/src/component.rs @@ -9,7 +9,9 @@ pub enum PlanetType { } #[derive(Component, Clone, Copy, Serialize, Deserialize, Debug)] -pub enum PartType { Hearty,} +pub enum PartType { + Hearty, +} #[derive(Component, Clone, Copy, Serialize, Deserialize, Debug, Default)] pub struct Input { diff --git a/starkingdoms-client/index.html b/starkingdoms-client/index.html index f6adf6fa6c8559ec39c0bb4ad06f1893cbcbcbc8..ea6a9c7dc607e13ee35917d8350bfb328c76bbd5 100644 --- a/starkingdoms-client/index.html +++ b/starkingdoms-client/index.html @@ -10,10 +10,11 @@ -