~starkingdoms/starkingdoms

321e32fc5c5439af1c396ff486d9be99d70cd36e — core 2 years ago 7a460d3
update hook to provide commands for invalid formatting
3 files changed, 8 insertions(+), 18 deletions(-)

M .git-hooks/pre-commit
M server/src/component.rs
M starkingdoms-client/index.html
M .git-hooks/pre-commit => .git-hooks/pre-commit +4 -11
@@ 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

M server/src/component.rs => server/src/component.rs +1 -3
@@ 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 {

M starkingdoms-client/index.html => starkingdoms-client/index.html +3 -4
@@ 10,11 10,10 @@
      <!-- Canvas gets added here by the game script -->
    </div>

    <div class="popup popup-center popup-max-width-300" id="server_selector">
      <h1>StarKingdoms</h1>
      <h2>Join Game</h2>
    <div class="popup popup-center popup-max-width-300" id="server_selector"><h1>StarKingdoms</h1>
         <h2>Join Game</h2>

      <form id="join-fm">
      <form id   =   "join-fm">
        <label>Choose server</label>

        <div class="fm-select">