mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-20 01:32:33 +02:00
Add pre-commit hook for vendorHash validation #7
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Executable
+27
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
CURRENT_HASH=$(grep -oP '(?<=vendorHash = ")[^"]+' flake.nix)
|
||||||
|
|
||||||
|
go mod vendor
|
||||||
|
|
||||||
|
COMPUTED_HASH=$(nix hash path vendor/)
|
||||||
|
|
||||||
|
rm -rf vendor/
|
||||||
|
|
||||||
|
if [ "$CURRENT_HASH" = "$COMPUTED_HASH" ]; then
|
||||||
|
echo "vendorHash is up to date"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Updating vendorHash in flake.nix..."
|
||||||
|
python3 -c "
|
||||||
|
import sys
|
||||||
|
with open('flake.nix', 'r') as f:
|
||||||
|
content = f.read()
|
||||||
|
content = content.replace('$CURRENT_HASH', '$COMPUTED_HASH')
|
||||||
|
with open('flake.nix', 'w') as f:
|
||||||
|
f.write(content)
|
||||||
|
"
|
||||||
|
echo " Old: $CURRENT_HASH"
|
||||||
|
echo " New: $COMPUTED_HASH"
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
pre-commit:
|
pre-commit:
|
||||||
piped: true
|
piped: true
|
||||||
commands:
|
commands:
|
||||||
|
check-vendor-hash:
|
||||||
|
glob: "{go.mod,go.sum}"
|
||||||
|
run: .github/scripts/check-vendor-hash.sh
|
||||||
|
stage_fixed: true
|
||||||
inject-exec-basics:
|
inject-exec-basics:
|
||||||
glob: "{docs/basics.md,cmd/**}"
|
glob: "{docs/basics.md,cmd/**}"
|
||||||
run: python3 .github/scripts/inject-exec.py docs/basics.md
|
run: python3 .github/scripts/inject-exec.py docs/basics.md
|
||||||
|
|||||||
Reference in New Issue
Block a user