diff --git a/justfile b/justfile index e3ffd9a..cb5a074 100644 --- a/justfile +++ b/justfile @@ -53,3 +53,6 @@ new-data-fix name: run-fixes: go run ./cmd/user run-fixes + +fix-all: + bash scripts/fix-all.sh diff --git a/scripts/fix-all.sh b/scripts/fix-all.sh new file mode 100755 index 0000000..00cc2bb --- /dev/null +++ b/scripts/fix-all.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +set -euo pipefail + +get_hash() { + find . -name "*.go" -type f ! -path "./vendor/*" -exec sha256sum {} + | sha256sum | cut -d' ' -f1 +} + +echo "running go fix recursively until no changes..." + +prev_hash=$(get_hash) +iteration=0 + +while true; do + iteration=$((iteration + 1)) + echo "iteration $iteration..." + + go fix ./... >/dev/null 2>&1 || true + + curr_hash=$(get_hash) + + if [[ "$prev_hash" == "$curr_hash" ]]; then + echo "no more changes after $iteration iteration(s)" + break + fi + + prev_hash=$curr_hash +done + +echo "done" \ No newline at end of file