On Thu, Mar 12, 2009 at 09:33:44AM -0300, Devan Goodwin wrote:
> 
> Works for me. Yeah I'd be in favor of the commit hook.

My first attempt at the hook which would catch commits that seems to
be automatic merges done during git pull is in the attachment.

-- 
Jan Pazdziora
Senior Software Engineer, Satellite Engineering, Red Hat
#!/bin/bash

while read old_sha1 new_sha1 refname ; do
        # echo "stdin: [$old_sha1] [$new_sha1] [$refname]"
        git rev-list --parents $old_sha1..$new_sha1 \
                | while read sha1 parents ; do
                        # echo "  commit: [$sha1] [$parents]"
                        if [ "${parents/ /}" != "$parents" ] ; then
                                # echo "   -> merge"
                                if ! ( git cat-file commit $sha1 \
                                        | perl -e 'BEGIN { $/ = "\n\n" }
                                                scalar(<>);
                                                my $msg = <>;
                                                if ($msg =~ /^Merge branch \S+ 
of \S+\n*$/s) {
                                                        exit 1
                                                }' ) ; then
                                        echo "Commit [$sha1] looks like 
automatic merge when you did not rebase after pull."
                                        exit 1
                                fi
                        fi
                done
        [ $? -ne 0 ] && exit 1
        :
done

exit $?

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to