Reputation: 21
I'd like to ask if there is a possible way that a hook is executed on git submodule update; possibly like a post-update hook? thanks! :)
I like to execute a script (for now it just contains echo msg) that is executed every time git submodule update is run.
I have tried post-update hook but it seems that submodule update does not trigger this. I'd appreciate help. thank you very much!
Upvotes: 0
Views: 2567
Reputation: 94473
Create an alias:
git config alias.sup !"git submodule update; my-post-sup-hook"
and always update submodules using the alias:
git sup
Upvotes: 2
Reputation: 1324178
A post-update, like a post-receive hook, would be a server-side hook.
So it is expected to not work locally (client side)
So there is no specific hook for a git submodule update
, which means you would need to script the git
command itself in a wrapper, to detect the submodule
argument, and chain that command with your echos.
Another convoluted approach is described in "git-submodule
with git-hooks — A way to scalable repositories" from Ashwini Kumar, where a pre-commit
hook is trigger by a git commit
(done after a git submodule update
), which will look at the diff introduced by said commit.
If the diff involves submodules, then it proceeds with additional commands.
Upvotes: 2