]> git.giacomolli.uk - onechat/blobdiff - bin/check
Check the width of comment lines
[onechat] / bin / check
index b8071dce37734bdbefa1586acc4ac2b949f89501..e8e6e97ab96350c2812da6853c9d5ee82152188b 100755 (executable)
--- a/bin/check
+++ b/bin/check
@@ -7,16 +7,25 @@ files() {
   git ls-files --cached --others --exclude-standard -- "$@"
 }
 
-unformatted=$(gofumpt -l .)
+unformatted=$(files '*.go' | xargs gofumpt -l)
 if [ -n "$unformatted" ]; then
   printf 'gofumpt: unformatted files:\n%s\n' "$unformatted" >&2
   exit 1
 fi
 
+# Comment lines stay within the width of bin/reflow, with tabs as 8 columns.
+long=$(files '*.go' | while read -r file; do
+  expand -t8 "$file" | awk -v file="$file" 'length > 80 && /^[[:space:]]*\/\//{print file ":" FNR}'
+done)
+if [ -n "$long" ]; then
+  printf 'comment lines over 80 columns, run bin/reflow:\n%s\n' "$long" >&2
+  exit 1
+fi
+
 go vet ./...
 golangci-lint run
-go test -race ./...
+go test -race -short ./...
 files '*.nix' | xargs nixfmt --check
 files '*.rst' | xargs rstfmt --check
 files '*.md' | xargs mdformat --check
-shellcheck bin/check bin/format bin/reflow .githooks/commit-msg
+shellcheck bin/check bin/format bin/reflow bin/service-update .githooks/commit-msg