Skip to content

Commit

Permalink
Only install pre-commit hook if it does not exist (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Sep 30, 2022
1 parent 0a5bfef commit 55af542
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions hatch_jupyter_builder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,10 @@ def install_pre_commit_hook():
log.warning("Refusing to install pre-commit hook since this is not a git repository")
return

path = ".git/hooks/pre-commit"
with open(path, "w") as fid:
fid.write(data)
path = Path(".git/hooks/pre-commit")
if not path.exists():
with open(path, "w") as fid:
fid.write(data)

mode = os.stat(path).st_mode
mode |= (mode & 0o444) >> 2 # copy R bits to X
Expand Down

0 comments on commit 55af542

Please sign in to comment.