
Doug,
--- save as .git/hooks/sendemail-validate --- #!/bin/sh
set -e
changeid=$(sed 's/^Change-Id: (I.*)$/\1/;t;d' $1) date=$(date +%s) sed 's/^Change-Id: I.*$//;T;d' -i $1 sed "s/^From: /Message-Id: $date-$changeid@changeid\nFrom: /" -i $1 #--- end script ---
Do you have any idea how to encourage adoption of your git hook? Would it make sense to do something like check it in to the Linux kernel somewhere?
I still don't really know, but I wanted to post that I changed it now, because of uniqueness problems if there *isn't* a changeid, and to make the format a bit more like yours:
--- save as .git/hooks/sendemail-validate --- #!/bin/bash
set -e
changeid=$(sed 's/^Change-Id: (I.*)$/\1/;t;d' $1) # let git do its own if there's no change-id [ "$changeid" = "" ] && exit 0
commit=$(sed 's/^From.*([0-9a-fA-F]{40}).*/\1/;t;d' $1) # must have a commit ID - if this fails git changed [ "$commit" == "" ] && exit 2
commit=${commit:0:12}
date=$(date +%Y%m%d%H%M%S)
# remove change-id sed 's/^Change-Id: I.*$//;T;d' -i $1 # and add message-id sed "s/^From: /Message-Id: $date.$commit.$changeid@changeid\nFrom: /" -i $1 #--- end script ---
(also at https://p.sipsolutions.net/a1ebdd33abb598b4.txt)
johannes