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

guarantee there are no pre-commit hooks #15

Closed
masukomi opened this issue Oct 22, 2022 · 1 comment
Closed

guarantee there are no pre-commit hooks #15

masukomi opened this issue Oct 22, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@masukomi
Copy link
Owner

masukomi commented Oct 22, 2022

issue #14 came into existence because of failing pre-commit hooks that were created via a templatedir git config directive.

As a general statement there should never be pre-commit hooks running in the private_comments repos, but templatedir usage is valid, and we shouldn't force users to not use it.

Instead, when a new project repo is created, we should check if there is an executable .git/pre-commit file if so we should remove its executable bit.

Additionally there should be a PRIVATE_COMMENT_ALLOW_PRE_COMMIT environment variable that is checked. If it's set to true this behavior should be skipped.

Testing

  1. define a templatedir that contains an executable at hooks/pre-commit & confirm that initializing a new repo on your computer adds that file at .git/hooks/pre-commit and that it's executable (ls -lash .git/hooks/pre-commit)
  2. leave a comment on a repo you haven't commented on before.
  3. check if the new repo has the expected copy of that pre-commit file at .git/hooks/pre-commit. If not, ... something's wonky that probably isn't anything to do with PC
  4. confirm that the file in the new PC repo is not executable, but is readable and writable. chmod 660 is what should have been run on it.
  5. repeat steps 2 & 3 but this time set the PRIVATE_COMMENTS_ALLOW_PRE_COMMIT environment variable to true before starting the private_comments server and confirm that the pre-commit remains executable.
@masukomi masukomi added the enhancement New feature or request label Oct 22, 2022
@masukomi masukomi self-assigned this Oct 22, 2022
@masukomi
Copy link
Owner Author

Fixed in v1.3.1

masukomi added a commit that referenced this issue Oct 23, 2022
if a user has a global templatedir directive in
their git config it can result in an executable
pre-commit being installed when the repo is
initialized.

this is never what we want. PC will now make that
NOT executable and disable the git warning about
it in that repo.

if, for some strange reason, you _do_ want a
pre-commit hook on your private comments commits
then you can set the "PRIVATE_COMMENTS_ALLOW_PRE_COMMIT"
environment variable to "true"

this commit also addresses issue #14 which was a side-effect
of this bad pre-commit state

TICKET: #15
FIXES #15
FIXES #14

TAGS: hooks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant