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

git hooks install is not installing hooks or is showing failing messages #170

Closed
giggio opened this issue May 2, 2024 · 9 comments · Fixed by #171
Closed

git hooks install is not installing hooks or is showing failing messages #170

giggio opened this issue May 2, 2024 · 9 comments · Fixed by #171

Comments

@giggio
Copy link

giggio commented May 2, 2024

I just ran git hooks install and nothing changed in .git/hooks. I ran it again and files showed up. I'm not sure what happened.
Now I ran again and got this:

❯ git hooks install
🦎 Installed '22' Githooks run-wrapper(s) into '/home/user/.dotfiles/.git/hooks'
⛑  Githooks are configured but Githooks seems not installed in '/home/user/.dotfiles/.git'.
   Neither 'core.hooksPath' set nor run-wrappers installed.
   Hooks might not run!

list is also listing errors. Hooks are installed, see output:

❯ ls -la .git/hooks/
drwxr-xr-x   - user user  2 May 01:24 .
drwxr-xr-x   - user user  2 May 01:24 ..
.rwxr-xr-x 754 user user  2 May 01:24 applypatch-msg
.rwxr-xr-x 754 user user  2 May 01:24 commit-msg
<REMOVED FOR BREVITY>

~/.dotfiles on  main 📝1⇡1                                                                                                                                                                         at 01:24:46 
❯ git hooks list
⛑  Githooks are configured but Githooks seems not installed in '/home/user/.dotfiles/.git'.
   Neither 'core.hooksPath' set nor run-wrappers installed.
   Hooks might not run!
🦎 Hook: 'pre-commit' [1]:
    Repository:
     • '01-shellcheck.sh'  :  state: ['active', 'trusted'], type: 'repo', ns-path: 'ns:gh-self/pre-commit/01-shellcheck.sh'
🦎 Total listed hooks: '1'.

I'm running git hooks from main, using nix.

@gabyx
Copy link
Owner

gabyx commented May 2, 2024

Seems weird and like a small bug I supposedly fixed?
After installing git hook install can you post the full ls -al $(git rev-parse --git-common-dir)/hooks. It should contain a githooks-contains-run-wrappers file. If not that is kind of weird. Are you sure that git hooks is using the build executable from Nix and not the ~/.githooks/bin thing still installed?

The relevant code which triggers this is :

if hasHooksConfigured &&
			!localCoreHooksPathSet && !globalCoreHooksPathSet &&
			!hasRunWrappers {

!hasRunWrappers is the not existence of githooks-contains-run-wrappers file inside the hook directory. Are you using workspaces?

BR

@gabyx
Copy link
Owner

gabyx commented May 2, 2024

I reproduced the bug, thanks for the report. Its just awrong warning. Trying to fix it.

@gabyx
Copy link
Owner

gabyx commented May 2, 2024

Found the typo in the warning logic: Fixing it in 30min, than it works hopefully.

@gabyx
Copy link
Owner

gabyx commented May 2, 2024

@giggio: You should probably prefer to install only a link (core.hooksPath) with git hooks install. You can do this by git hooks uninstall and cleaning git config githooks.maintainedHooks (this settings will force run-wrappers into the current repo). You can set this to a meaningful value globally when git hooks installer runs, to just maintain a set of meaningful hooks in the Githooks hooksDir (=<install-prefix>/templates/hooks)

@gabyx gabyx closed this as completed in #171 May 2, 2024
@giggio
Copy link
Author

giggio commented May 2, 2024

I am no longer seeing failing messages, but I still see the bug of not installing:
image

But something ran, I see githooks.registered is now set to true.

@gabyx
Copy link
Owner

gabyx commented May 2, 2024

it installed, it set the core.hooksPath.

@gabyx gabyx reopened this May 2, 2024
@gabyx gabyx closed this as completed May 2, 2024
@giggio
Copy link
Author

giggio commented May 2, 2024

Oh, yes, it did. So now we don't need the run wrappers on the local directory anymore? Ok, cool!

@gabyx
Copy link
Owner

gabyx commented May 3, 2024

@giggio: Correct, it will only use run-wrappers on the local directory when you use --maintained-hooks on git hooks install

@gabyx
Copy link
Owner

gabyx commented May 3, 2024

You can also use that on githooks-installer

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 a pull request may close this issue.

2 participants