summaryrefslogtreecommitdiffstats
path: root/git_hooks/prepare-commit-msg
blob: 050e17c370ddf6786e8f71c6bfd8b90ffd9bdf58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
#
# Hook used to produce a commit message based on CHANGES
#

FILE="$1"
SOURCE="$2"
COMMIT="$3"

case $SOURCE in
    'merge')
        # On merges adds the commit messages found in CHANGES
        TMP=`mktemp 2> /dev/null || mktemp -t 'mytmpdir'` && \
            cat $FILE >$TMP && \
            sed -i '/^Merge.*/d' $TMP && \
            git diff --cached scilab/CHANGES* |sed -n '/^+/p' |sed -n '/^+++/!p' |sed 's/^.\{1\}//g' >$FILE && \
            cat $TMP >>$FILE && \
            rm $TMP
        ;;

    '')
        # On normal commit add messages found in CHANGES
        TMP=`mktemp 2> /dev/null || mktemp -t 'mytmpdir'` && \
            cat $FILE >$TMP && \
            git diff --cached scilab/CHANGES* |sed -n '/^+/p' |sed -n '/^+++/!p' |sed 's/^.\{1\}//g' >$FILE && \
            cat $TMP >>$FILE && \
            rm $TMP
        ;;
    *)
        ;;
esac