diff --git a/build.sh b/build.sh index c0a624e..31ca658 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + PROJECT="sindri" VERSION="dev-$(date -u '+%Y-%m-%d')-$(git rev-parse --short HEAD)" diff --git a/fmt.sh b/fmt.sh index 072748d..c89001d 100755 --- a/fmt.sh +++ b/fmt.sh @@ -1,3 +1,6 @@ #!/bin/sh -odinfmt -w src/ +set -e + +odinfmt -w src/ > /dev/null +odinfmt -w tests/ > /dev/null diff --git a/scripts/pre-commit b/scripts/pre-commit index 3dd43ff..c88d146 100755 --- a/scripts/pre-commit +++ b/scripts/pre-commit @@ -2,5 +2,17 @@ SCRIPT_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd) +git stash push --keep-index --quiet + "$SCRIPT_DIR/../fmt.sh" + +if ! git diff --quiet; then + echo "Formatting changed staged files; commit aborted." + git checkout -- "$SCRIPT_DIR/.." + git stash pop --quiet + exit 1 +fi + "$SCRIPT_DIR/../test.sh" + +git stash pop --quiet diff --git a/tests/blabla.odin b/tests/blabla.odin index a75f317..e1e8192 100644 --- a/tests/blabla.odin +++ b/tests/blabla.odin @@ -4,5 +4,5 @@ import "core:testing" @(test) foo :: proc(t: ^testing.T) { - testing.expect(t, 1 + 1 == 2, "pass") + testing.expect(t, 1 + 1 == 2, "pass") }