feat: add fix-all script for recursive go fix
This commit is contained in:
3
justfile
3
justfile
@@ -53,3 +53,6 @@ new-data-fix name:
|
|||||||
|
|
||||||
run-fixes:
|
run-fixes:
|
||||||
go run ./cmd/user run-fixes
|
go run ./cmd/user run-fixes
|
||||||
|
|
||||||
|
fix-all:
|
||||||
|
bash scripts/fix-all.sh
|
||||||
|
|||||||
29
scripts/fix-all.sh
Executable file
29
scripts/fix-all.sh
Executable file
@@ -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"
|
||||||
Reference in New Issue
Block a user