Skip to content

Commit

Permalink
Merge pull request #12 from YeetCode-devs/staging/hakimi
Browse files Browse the repository at this point in the history
Implement pre-commit hook
  • Loading branch information
pranayadmn committed Mar 18, 2024
2 parents 2d8aa5b + 7edee2f commit 96d1954
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions scripts/install_hook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os

from pathlib import Path

SCRIPT = r"""#!/bin/sh
set -o noglob
python3 scripts/install_hook.py
poetry run black .
for file in $(git diff --cached --name-only); do
test -f $file && git add $file
done"""


def main() -> None:
print("Installing pre-commit hook")
with open(".git/hooks/pre-commit", "w") as f:
f.write(SCRIPT)

print(f"Installing dev dependencies (for black)")
os.system("poetry install --with dev")
Path(".git/hooks/pre-commit").chmod(0o700)


main()

0 comments on commit 96d1954

Please sign in to comment.