Explorar el Código

chore: update flakebox files

thesimplekid hace 1 año
padre
commit
003ecb9dba
Se han modificado 5 ficheros con 20 adiciones y 13 borrados
  1. 1 0
      .config/flakebox/.gitignore
  2. 1 1
      .config/flakebox/id
  3. 1 0
      .rustfmt.toml
  4. 10 10
      justfile
  5. 7 2
      misc/git-hooks/pre-commit

+ 1 - 0
.config/flakebox/.gitignore

@@ -0,0 +1 @@
+tmp/

+ 1 - 1
.config/flakebox/id

@@ -1 +1 @@
-437409787773bc012f713d609c43406e98174dca8d94911ed7905618cc62f2d026781205d6583645176c630878fe6a238e3a17b85254677c632ec4c25b699a4a
+4554d31c5e79420d5b097aad56a49a1c61bb89f32d6b93fb5ff4d0677bc9b587e3426e881d01f5551ff816cfcec2941d0529130f491f6098abb64e6c28592c94

+ 1 - 0
.rustfmt.toml

@@ -2,3 +2,4 @@ group_imports = "StdExternalCrate"
 wrap_comments = true
 format_code_in_doc_comments = true
 imports_granularity = "Module"
+edition = "2021"

+ 10 - 10
justfile

@@ -11,23 +11,23 @@ default:
 
 
 # run `cargo build` on everything
-build:
+build *ARGS="--workspace --all-targets":
   #!/usr/bin/env bash
   set -euo pipefail
   if [ ! -f Cargo.toml ]; then
     cd {{invocation_directory()}}
   fi
-  cargo build --workspace --all-targets
+  cargo build {{ARGS}}
 
 
 # run `cargo check` on everything
-check:
+check *ARGS="--workspace --all-targets":
   #!/usr/bin/env bash
   set -euo pipefail
   if [ ! -f Cargo.toml ]; then
     cd {{invocation_directory()}}
   fi
-  cargo check --workspace --all-targets
+  cargo check {{ARGS}}
 
 
 # run all checks recommended before opening a PR
@@ -70,22 +70,22 @@ test: build
 
 
 # run and restart on changes
-watch:
+watch *ARGS="-x run":
   #!/usr/bin/env bash
   set -euo pipefail
   if [ ! -f Cargo.toml ]; then
     cd {{invocation_directory()}}
   fi
-  env RUST_LOG=${RUST_LOG:-debug} cargo watch -x run
+  env RUST_LOG=${RUST_LOG:-debug} cargo watch {{ARGS}}
 
 
 # run `cargo clippy` on everything
-clippy:
-  cargo clippy --locked --offline --workspace --all-targets -- --deny warnings --allow deprecated
+clippy *ARGS="--locked --offline --workspace --all-targets":
+  cargo clippy {{ARGS}} -- --deny warnings --allow deprecated
 
 # run `cargo clippy --fix` on everything
-clippy-fix:
-  cargo clippy --locked --offline --workspace --all-targets --fix
+clippy-fix *ARGS="--locked --offline --workspace --all-targets":
+  cargo clippy {{ARGS}} --fix
 
 
 # run `semgrep`

+ 7 - 2
misc/git-hooks/pre-commit

@@ -132,8 +132,13 @@ export -f check_trailing_newline
 function check_trailing_whitespace() {
     set -euo pipefail
 
-    if ! git diff --check HEAD ; then
-      echo "Trailing whitespace detected. Please remove them before committing."
+    rev="HEAD"
+    if ! git rev-parse -q 1>/dev/null HEAD 2>/dev/null ; then
+      >&2 echo "Warning: no commits yet, checking against --root"
+      rev="--root"
+    fi
+    if ! git diff --check $rev ; then
+      >&2 echo "Trailing whitespace detected. Please remove them before committing."
       return 1
     fi