Skip to contentSkip to conversation

merge hook

DISCUSSION Erik Colson 2 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hello,

Is it possible to launch a custom script on all files involved in a merge to master ?
If yes, is it then also possible to reject the merge if the script returns an error ?

Thanks
--
Erik

#1 lore raw

Hi,

Quoted 5 lines · Erik Colson

Is it possible to launch a custom script on all files involved in a merge to master ? If yes, is it then also possible to reject the merge if the script returns an error ?

From Documentation/githooks.txt:

-- snip --
prepare-commit-msg
------------------

This hook is invoked by 'git-commit' right after preparing the default log message, and before the editor is started.

It takes one to three parameters. The first is the name of the file that the commit log message. The second is the source of the commit message, and can be: [...] merge (if the commit is a merge or a .git/MERGE_MSG file exists); [...]

If the exit status is non-zero, 'git-commit' will abort. -- snap --

To see which files are affected, you'd just need to ask "git diff --name-only --cached".

I guess that you want to disallow merging in changes from people who changed files that are none of their business? If so, it would be nice to contribute the hook as a patch to contrib/.

Ciao,
Dscho

#2 lore raw

On Fri, Oct 10, 2008 at 12:07:16PM +0200, Johannes Schindelin wrote:

[..]

Quoted 1 line

From Documentation/githooks.txt:

thank you for pointing me there

[..]

Quoted 3 lines

I guess that you want to disallow merging in changes from people who changed files that are none of their business? If so, it would be nice to contribute the hook as a patch to contrib/.

wrong guess ;)
The purpose is to check if source code still has debug code in it. Our policy is to have it removed before reaching master, but checking by hand is way too buggy ;)

--
erik

#3 lore raw

Hi,

Quoted 9 lines · Erik Colson
Quoted 3 lines · Johannes Schindelin

I guess that you want to disallow merging in changes from people who changed files that are none of their business? If so, it would be nice to contribute the hook as a patch to contrib/.

wrong guess ;) The purpose is to check if source code still has debug code in it. Our policy is to have it removed before reaching master, but checking by hand is way too buggy ;)

Heh. Still, if it is not too specific, would be nice to have it in contrib/. So I can point other people to it ;-)

Ciao,
Dscho