threads / discuss / 13497

multiple files for the same hook

Subject: multiple files for the same hook

## tl;dr

6 messages between May 12, 2008 and May 13, 2008.

replies: 5people: 5as markdown or json

Thomas Hunger· May 12, 2008, 20:39 UTC · lore
Hi,

we use hooks a lot for various cleanup tasks, tests and warnings. It would be wonderful if we could keep the hook logic in separate files.

Something like
    hooks/post-commit.d/

where all executable files in the dir are executed in alphanumeric order. Is there a possibility of this going into git (I could try a patch)?

Tom
Sverre Rabbelier· May 12, 2008, 20:43 UTC · re: Thomas Hunger · lore

Re: multiple files for the same hook

On Mon, May 12, 2008 at 10:39 PM, Thomas Hunger <hto@arcor.de> wrote:
>  where all executable files in the dir are executed in alphanumeric
>  order. Is there a possibility of this going into git (I could try a
>  patch)?
Heya,

Wouldn't it be easy to have the hook script do that? Just have it walk through the directory and call all the scripts?

-- 
Cheers,

Sverre Rabbelier
Miklos Vajna· May 12, 2008, 20:44 UTC · re: Thomas Hunger · lore

Re: multiple files for the same hook

On Mon, May 12, 2008 at 08:39:49PM +0000, Thomas Hunger <hto@arcor.de> wrote:
Show 10 quoted lines
> we use hooks a lot for various cleanup tasks, tests and warnings. It 
> would be wonderful if we could keep the hook logic in separate files. 
> 
> Something like
> 
>     hooks/post-commit.d/
> 
> where all executable files in the dir are executed in alphanumeric 
> order. Is there a possibility of this going into git (I could try a 
> patch)?

why would you want so? just create a script named hooks/post-commit, like:

---- #!/bin/sh /path/to/first/script /path/to/second/script ----

or so.
it's not something git should do for you.
Thomas Hunger· May 12, 2008, 21:56 UTC · re: Miklos Vajna · lore

Re: multiple files for the same hook

Miklos, Sverre,
> why would you want so? just create a script named
> hooks/post-commit, like:

you are right, it's what we actually do, using --template to set up our own scripts. If nobody but us needs this it's certainly not worth bothering.

Thanks Tom

Jeff King· May 13, 2008, 04:21 UTC · re: Thomas Hunger · lore

Re: multiple files for the same hook

On Mon, May 12, 2008 at 09:56:30PM +0000, Thomas Hunger wrote:
Show 6 quoted lines
> > why would you want so? just create a script named
> > hooks/post-commit, like:
> 
> you are right, it's what we actually do, using --template to set up 
> our own scripts. If nobody but us needs this it's certainly not worth 
> bothering.

The problem is that the semantics of calling some of the hooks is not as simple as just calling them all in a row. How do you split up the input going to the hooks? How do you combine the output coming from the hooks? What is the resulting exit code? If one hook fails, do we indicate failure? Or if one hook succeeds, do we indicate success?

So before any such code could go into git proper, there would have to be agreement on how those issues are resolved. In the meantime, it probably makes more sense to implement a "master" post-commit hook that uses the semantics that you find useful.

-Peff
Martin Langhoff· May 13, 2008, 08:05 UTC · re: Jeff King · lore

Re: multiple files for the same hook

On Tue, May 13, 2008 at 4:21 PM, Jeff King <peff@peff.net> wrote:
>  In the meantime, it probably
>  makes more sense to implement a "master" post-commit hook that uses the
>  semantics that you find useful.

And when you are implementing those semantics, you might be able to reuse "run-parts" which does roughly what you want.

:-)
cheers,
m
--
 martin.langhoff@gmail.com
 martin@laptop.org -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff

← back to recent threads