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

Different versions cross git worktree #192

Closed
ryuran opened this issue May 17, 2021 · 4 comments · Fixed by #193
Closed

Different versions cross git worktree #192

ryuran opened this issue May 17, 2021 · 4 comments · Fixed by #193
Assignees
Labels
bug Something isn't working

Comments

@ryuran
Copy link

ryuran commented May 17, 2021

Hello

I still encounter an issue with 0.7.5 in a worktree #180

Error message:

This command must be executed within git repository.
Change working directory or initialize new repository with 'git init'.

  • main git directory : lefthook 0.7.4
  • git worktree directory : lefthook 0.7.5

It seems to use the lefthook version from the original git directory instead of the curren one.

@Envek
Copy link
Member

Envek commented May 17, 2021

How do you have installed lefthook? Most probably from Ruby gem or NPM? This is probably not Lefthook issue, I believe.

@Envek Envek added the waiting for response We need more details or confirmation label May 17, 2021
@ryuran
Copy link
Author

ryuran commented May 17, 2021

With npm as a dev-dependency.

@Envek Envek removed the waiting for response We need more details or confirmation label May 17, 2021
@Envek
Copy link
Member

Envek commented May 17, 2021

Ok, I found what's wrong. Here we search for lefthook binary relative to hooks directory path which is by default is relative to main worktree:

dir="$(cd "$(dirname "$(dirname "$(dirname "$0")")")" >/dev/null 2>&1 || exit ; pwd -P)"
call_lefthook()
{
if lefthook -h >/dev/null 2>&1
then
eval $1
elif test -f "$dir/node_modules/@arkweid/lefthook/bin/lefthook"
then
eval $dir/node_modules/@arkweid/lefthook/bin/$1

Most probably we need to search relative to current working directory or something like that.

@Envek
Copy link
Member

Envek commented Jun 2, 2021

Fix was just released in 0.7.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants