Skip to contentSkip to conversation

multiple files for the same hook

DISCUSSION Thomas Hunger 5 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 10 lines · Thomas Hunger

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.

#2 lore raw

Miklos, Sverre,

Quoted 2 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.

Thanks
Tom

#3 lore raw
Quoted 6 lines · Thomas Hunger
Quoted 2 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

#4 lore raw
Quoted 3 lines · Jeff King

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
--
[email protected]
[email protected] -- School Server Architect
- ask interesting questions
- don't get distracted with shiny stuff - working code first
- http://wiki.laptop.org/go/User:Martinlanghoff

#5 lore raw
In reply to Thomas Hunger
Quoted 3 lines · Thomas Hunger

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?

Signature · 3 lines
Cheers,

Sverre Rabbelier