From 321e32fc5c5439af1c396ff486d9be99d70cd36e Mon Sep 17 00:00:00 2001 From: core Date: Mon, 27 Nov 2023 11:39:21 -0500 Subject: [PATCH] update hook to provide commands for invalid formatting --- .git-hooks/pre-commit | 15 ++++----------- server/src/component.rs | 4 +--- starkingdoms-client/index.html | 7 +++---- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index 5c8b60d846fc6ab9c1d72c31dd9b07d1e647b1aa..d9512bf7c4acacd90ab93e16d90b1dca3ae07480 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -3,20 +3,16 @@ echo "Checking your formatting..." HAS_ISSUES=0 -FIRST_FILE=1 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 - if [ $FIRST_FILE -eq 0 ]; then - echo -n ", " - fi echo -n "$file (rustfmt)" HAS_ISSUES=1 - FIRST_FILE=0 fi done +FIRST_FILE=1 cd starkingdoms-client for file in $(git diff --name-only --staged); do @@ -24,9 +20,9 @@ for file in $(git diff --name-only --staged); do FMT_RESULT="$(yarn prettier $file --check 2>&1 > /dev/null || true)" if [ "$FMT_RESULT" != "" ]; then if [ $FIRST_FILE -eq 0 ]; then - echo -n ", " + echo "cd starkingdoms-client" fi - echo -n "$file (prettier)" + echo -n "yarn prettier $file --write" HAS_ISSUES=1 FIRST_FILE=0 fi @@ -38,8 +34,5 @@ if [ $HAS_ISSUES -eq 0 ]; then exit 0 fi -echo "" -echo ". Your code has formatting issues in files listed above. Format each file before proceeding with commit." -echo ". For Rust files, execute 'rustfmt path/to/file.rs' in 'server/'." -echo ". For client files, execute 'yarn prettier path/to/file --write' in 'starkingdoms-client/'." +echo "!! Some files have formatting issues! Run all of the above commands, and then attempt another commit." exit 1 diff --git a/server/src/component.rs b/server/src/component.rs index 79ae11d40ff17c7f6f822b57eea923c92cfce95c..a0391186afbaaea29158a020c8aadafdb6ccc6ae 100644 --- a/server/src/component.rs +++ b/server/src/component.rs @@ -9,9 +9,7 @@ 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 ea6a9c7dc607e13ee35917d8350bfb328c76bbd5..f6adf6fa6c8559ec39c0bb4ad06f1893cbcbcbc8 100644 --- a/starkingdoms-client/index.html +++ b/starkingdoms-client/index.html @@ -10,11 +10,10 @@ -