Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install git pre-commit hook only if there's a directory to put it in #604

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

umlaeute
Copy link

@umlaeute umlaeute commented Mar 7, 2023

The assumption that we can put a file into .git/hooks/ if .git exists is wrong, e.g. if .git is a file (as is the case when using git submodule).

This PR fixes the issue by checking if .git/hooks/ exists instead:

  • the trailing slash checks for directories (or: directory-likes) rather than for mere existence (regardless of type)
  • since we want to put the target file into the hooks/ subdirectory we just check for that (just in case the .git directory is weird)

Closes: #603

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GitHooks does not handle running in submodules
1 participant