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

Hook wrappers do not pass on hook parameters given by git #72

Open
chfr opened this issue Aug 10, 2020 · 2 comments
Open

Hook wrappers do not pass on hook parameters given by git #72

chfr opened this issue Aug 10, 2020 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@chfr
Copy link

chfr commented Aug 10, 2020

Hi!
For some hooks (for example commit-msg), git will call the hook with the path to the file containing the commit message (almost always .git/COMMIT_EDITMSG). From man githooks:

   commit-msg
       This hook is invoked by git commit, and can be bypassed with the --no-verify option. 
       It takes a single parameter, the name of the file that holds the proposed commit log message.

However, the hooks4git wrappers discard these parameters:

$ cat .git/hooks/commit-msg
#!/bin/bash
if [ -x "$(command -v hooks4git)" ]; then
    hooks4git -t $(basename $0)
fi

Is there a reason that hooks4git cannot pass these parameters on to the hooks? I tried adding "$@" to the end of the hooks4git command but that obviously didn't work out of the box :)
Thanks!

@lovato
Copy link
Owner

lovato commented Dec 14, 2020

Sorry not seeing that before. Let me look into it.

@lovato
Copy link
Owner

lovato commented Dec 14, 2020

Well, the $(basename $0) is just to get the name of the hook being triggered, so I can forward that information to inside H4G.
$0 is the calling script name inside your project .git hooks folder.

Not sure if I fully got it, but can you explain what are you trying to get solved? This piece of code does what it needs to do.
The git operation happens, a hook is called, I intercept that and propagate that into hooks4git logic, it runs the analysis, and provides a 0 or 1 back to git caller executable. Then, and only then, git workflow actually finalizes, outside hooks4git logic.

@lovato lovato added the question Further information is requested label Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants