hgeditor
changeset 684 4ccf3de52989
parent 683 104d2aee3b44
child 754 3e73bf876f17
equal deleted inserted replaced
683:104d2aee3b44 684:4ccf3de52989
     1 #!/bin/sh
     1 #!/bin/sh
     2 #
     2 #
     3 # This is an example of using HGEDITOR to automate the signing of
     3 # This is an example of using HGEDITOR to automate the signing of
     4 # commits and so on.
     4 # commits and so on.
       
     5 
       
     6 # change this to one to turn on GPG support
       
     7 SIGN=0
     5 
     8 
     6 T1=""; T2=""
     9 T1=""; T2=""
     7 cleanup_exit() {
    10 cleanup_exit() {
     8     rm -f "$T1" "$T2"
    11     rm -f "$T1" "$T2"
     9     exit $1
    12     exit $1
    38         done
    41         done
    39     )
    42     )
    40 
    43 
    41     CHECKSUM=`md5sum "$T1"`
    44     CHECKSUM=`md5sum "$T1"`
    42     $EDITOR "$T1" "$T2" || cleanup_exit $?
    45     $EDITOR "$T1" "$T2" || cleanup_exit $?
    43     echo "$CHECKSUM" | md5sum -c 2>/dev/null && cleanup_exit 13
    46 
    44     {
    47     if [ "$SIGN" == "1" ] ; then
    45         head -n 1 "$T1"
    48 	echo "$CHECKSUM" | md5sum -c 2>/dev/null && cleanup_exit 13
    46         echo
    49 	{
    47         grep -v "^HG:" "$T1" | gpg -t -a -u "${HGUSER}" --clearsign
    50 	    head -n 1 "$T1"
    48     } > "$T2" && mv "$T2" "$1"
    51 	    echo
       
    52 	    grep -v "^HG:" "$T1" | gpg -t -a -u "${HGUSER}" --clearsign
       
    53 	} > "$T2" && mv "$T2" "$1"
       
    54     else
       
    55 	mv "$T1" "$1"
       
    56     fi
    49     cleanup_exit $?
    57     cleanup_exit $?
    50 fi
    58 fi
    51 
    59