Spaces:
Sleeping
Sleeping
Download scripts/install_hooks.py from defenestrate/learning-world-goliath: direct link, hf CLI and curl.
- Browser
- Download file 678 Bytes
-
https://huggingface.co/spaces/defenestrate/learning-world-goliath/resolve/main/scripts/install_hooks.py
- Command line
-
hf download hf://spaces/defenestrate/learning-world-goliath/scripts/install_hooks.py
-
curl -L -o install_hooks.py https://huggingface.co/spaces/defenestrate/learning-world-goliath/resolve/main/scripts/install_hooks.py
678 Bytes
| """Install (or --check) the tracked pre-commit hook. Tolk pattern: edit tracked source, never .git/hooks directly.""" | |
| import shutil | |
| import stat | |
| import sys | |
| from pathlib import Path | |
| SRC = Path("scripts/hooks/pre-commit.sh") | |
| DST = Path(".git/hooks/pre-commit") | |
| def main() -> int: | |
| if "--check" in sys.argv: | |
| drifted = (not DST.exists()) or DST.read_bytes() != SRC.read_bytes() | |
| print("hook DRIFTED" if drifted else "hook ok") | |
| return 1 if drifted else 0 | |
| shutil.copyfile(SRC, DST) | |
| DST.chmod(DST.stat().st_mode | stat.S_IEXEC) | |
| print(f"installed {SRC} -> {DST}") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |