evilmartians / lefthook

Fast and powerful Git hooks manager for any type of projects.
MIT License
4.89k stars 213 forks source link

Is LFS Supported? #55

Closed gabyx closed 4 years ago

gabyx commented 5 years ago

Are the hooks from Git LFS supported? They probably should be run internally?...

Arkweid commented 5 years ago

We support this list of hooks: https://github.com/Arkweid/lefthook/blob/master/cmd/install.go#L18-L36

sr9992 commented 4 years ago

I'm trying to get Lefthook to run Git LFS' suggested pre-push hook:

#!/bin/sh
git lfs pre-push "$@"

but when it gets executed by Lefthook, it hangs indefinitely. I believe this is because git lfs pre-push is trying to read from stdin, as is documented here:

Information about what is to be pushed is provided on the hook’s standard input with lines of the form: <local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF

Does Lefthook pass this information to scripts? Or am I doing something wrong? Thanks!

Arkweid commented 4 years ago

Lefthook pass information from script into. But I don't sure about this case. You can check .git/hooks/pre-push file for debug it.

muuvmuuv commented 2 years ago

This should be documented somewhere as a side effect, otherwise lefthook will override it:

Oh sorry, that does not work, it prints:

 This should be run through Git's pre-push hook.  Run `git lfs update` to install it.

post-commit:
  commands:
    lfs:
      run: git lfs post-commit {0}

pre-push:
  commands:
    lfs:
      run: git lfs pre-push {0}

post-checkout:
  commands:
    lfs:
      run: git lfs post-checkout {0}

post-merge:
  commands:
    lfs:
      run: git lfs post-merge {0}
muuvmuuv commented 2 years ago

Still, I think this can be re-opened, git lfs hooks aren't executed and therefore lfs changes aren't pushed to the server. Adding lfs hooks to lefthook does not work, idk what lfs is missing in path, but it exits silently and lefthook will hang. I did not find any workaround yet...

Simple question: would it work importing lfs as a go-mod and use it directly "if it is installed"?

gabyx commented 2 years ago

FYI: In https://github.com/gabyx/Githooks we run them internally.

muuvmuuv commented 2 years ago

@gabyx cool, thanks! Unfortunately, the reason we use lefthook is that I can easily install it via Homebrew (or others) and with NPM, which we use, since some of our employees use windows and have all kind of problems installing binaries ^^.