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

npx simple-git-hooks #958

Closed
nemonemi opened this issue Mar 30, 2021 · 7 comments · Fixed by #960
Closed

npx simple-git-hooks #958

nemonemi opened this issue Mar 30, 2021 · 7 comments · Fixed by #960

Comments

@nemonemi
Copy link

Description

I have re-run the npx mrm lint-staged on the previously setup lint-staged with husky project.
When I ran the git commit nothing happened.
Then I went to the simple-git-hooks docs and found out that the hooks should be generated first by running the npx simple-git-hooks.

Is this something that was supposed to happen automatically when running the npx mrm lint-staged?

If yes, then there's a bug, because it hasn't happened to me.
If no, then the docs should instruct on doing so, however, in this case, how can this be integrated into the project, so that it happens automatically for everyone using the repo where lint staged and simple-git-hooks are applied?

Environment

  • OS: Windows 10
  • Node.js: v14.16.0
  • lint-staged: 10.5.4
@okonet
Copy link
Collaborator

okonet commented Mar 30, 2021

Hmm it worked for me on the new project so I guess it’s related to the fact that it’s an existing one which probably already has hook setup. Please try removing your hooks by uninstalling husky and then re-run the command.

@iiroj
Copy link
Member

iiroj commented Mar 30, 2021

Maybe it's the issue mentioned in the readme:

@jvfresco
Copy link

It happened exactly the same to me too. I just did the same npx simple-git-hooks and it started working again

ILyaCyclone added a commit to ILyaCyclone/otus-reactjs-hw that referenced this issue Mar 30, 2021
1) npx mrm lint-staged
2) npx simple-git-hooks (lint-staged/lint-staged#958)
3) `git config core.hooksPath` should be empty or point to `.git/hooks/`.
Otherwise call `git config --unset core.hooksPath` or `git config core.hooksPath .git/hooks/`.
@nemonemi
Copy link
Author

nemonemi commented Mar 31, 2021

If the project was already set up, this type of change would mean that it would have to be applied on every user's machine. I think this adds a lot of communication overhead and is error-prone.

How could this be mitigated so that once a person updates the repo with this change, he can perform all the changes needed and not having to communicate the change to everyone using it?

By the way, the command git config core.hooksPath for me doesn't return .husky, or anything else, for that matter.

@okonet
Copy link
Collaborator

okonet commented Mar 31, 2021

Yeah I guess it’s a breaking change and we’re considering moving back to husky but it requires some thinking. Ultimately we need to adjust the mrm package that’s responsible for the installation.

@iiroj
Copy link
Member

iiroj commented Mar 31, 2021

I think the mrm setup script for lint-staged could add a "postinstall": "npx simple-git-hooks" script to the repo's package.json.

This seems to work pretty well for a widely-used repo, because it will essentially re-install the hooks every time npm install or npm ci is run.

Now obviously this won't work on library repos that themselves get installed into other repos.

@iiroj
Copy link
Member

iiroj commented Mar 31, 2021

To be fair with husky v6 there's a similar issue, since it no longer automatically installs the git hooks and you have to separately call npx husky install.

@iiroj iiroj linked a pull request Apr 1, 2021 that will close this issue
@iiroj iiroj closed this as completed in #960 Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants