1

I want to add a message when pushing something, say:

"Hey, you should run `bower install` after this pull"

And this message should appear when somebody pulls from the repository. Actually, there's nothing better than a scream in the office but I'm looking for something better.

Ps: this isn't a problem that commit message can solve, in my opinion.

Mathias Müller
  • 22,203
  • 13
  • 58
  • 75
Daniele Vrut
  • 2,835
  • 2
  • 22
  • 32
  • Setup a post hook and connect it to something like a arduino board which is connected to a speaker. – PeeHaa Dec 19 '13 at 10:03
  • 1
    Your build system should do the right thing and detect the obsolete version of "bower". There's no reason to require your programmers to remember about all the details of what "bower" version is compatible with the HEAD of your work. – Tadeusz A. Kadłubowski Dec 19 '13 at 10:03
  • @TadeuszA.Kadłubowski: I sayd **bower install** and not **npm install bower**. A script in Gruntfile.js that checks something like: **newer:bower.json** should solve but is not the main question ;) – Daniele Vrut Dec 19 '13 at 10:07
  • 1
    I don't know what bower is and I don't know what npm is. My point was that there should be one canonic script that will handle all the details needed to run your application, whatever it might be. Your question is "how do I communicate some technical detail of the build process to the team?" My answer is: "you don't". It's better to automatize it away. Your programmers are busy as it is. Give them one easy to use tool that recompiles, restarts, redeploys, runs this `bower install`, etc. whenever necessary. One command like `make` to remember, and that's all. – Tadeusz A. Kadłubowski Dec 20 '13 at 10:29

2 Answers2

1

You can do it with a script attached to a push hook or pre-push hook. Here the documentation.

Atropo
  • 12,231
  • 6
  • 49
  • 62
1

There is not a dedicated pull hook, but every pull (that has content to pull in) performs a merge. There is a post-merge hook. Since you only need to warn to check external components when the code base has been updated therfore this is correct for the situation.

Hooks are just specially named executable scripts inside your .git/hooks folder

touch .git/hooks/post-merge
chmod u+x .git/hooks/post-merge
vim .git/hooks/post-merge

#!/bin/sh
echo "Hey, you should run `bower install` after this pull"

Hooks are not part of the repository though and therefore not distributed. One method of dealing with this is to create a controlled hooks folder and a script which symlinks them.

bin/create-hook-symlinks
hooks/post-merge

Where post-merge is the file you have already created, the linking script would be:

touch bin/create-hook-symlinks
chmod u+x bin/create-hook-symlinks
vim   bin/create-hook-symlinks

#!/bin/sh
ln hooks/post-merge .git/hooks/post-merge

On OS X I could not get the soft-link to execute, updated to hardlink.

Linked Question Is there any git hook for pull?

More info Git hook Docs & Hook tutorial.

Community
  • 1
  • 1
Morgan
  • 19,934
  • 8
  • 58
  • 84
  • And I'm pretty sure you could restrict it to pulls by checking ORIG_HEAD against the branch's remote-tracking head. – jthill Dec 23 '13 at 19:02