X-Git-Url: https://git.madduck.net/code/fbi-announce.git/blobdiff_plain/c853b83790da6402b7a6f4b954b9503c23dfef7e..c48b30c6a0eb568e625df42b5310dc3705eced5d:/fbi-announce.sh diff --git a/fbi-announce.sh b/fbi-announce.sh index b845bd8..7084136 100755 --- a/fbi-announce.sh +++ b/fbi-announce.sh @@ -21,8 +21,8 @@ # hooks.fbi-refwidth the width of references to show (default 7) # hooks.fbi-noisy include the entire log message in the announcement # hooks.fbi-msg-template the template for the message to be sent (default: -# [@@component@@/]@@project@@: @@author@@: \ -# @@logmessage@@ [@@ref@@] @@url@@) +# {@@component@@/}@@project@@[@@ref@@]: @@author@@: \ +# @@logmessage@@ [@@url@@]) # # The hook is meant ot be run from the Git post-receive hook. # @@ -71,7 +71,7 @@ url=$(echo "$url" | sed -e "s,@@sha1@@,${merged},") rawcommit=$(git cat-file commit ${merged}) author=$(echo "${rawcommit}" | sed -rne 's,^author (.+) <.*,\1,p') -logmessage=$(echo "${rawcommit}" | sed -e '1,/^$/d;s,&,\&,g;s,<,\<,g;s,>,\>,g') +logmessage=$(echo "${rawcommit}" | sed -e '1,/^$/d') ${noisy} || logmessage=$(echo "${logmessage}" | head -n2) ts=$(echo "${rawcommit}" | sed -n -e '/^author .*> \([0-9]\+\).*$/s--\1-p') @@ -79,18 +79,24 @@ ts=$(date -d "@${ts}") msg=$(git config hooks.fbi-msg-template 2>/dev/null ||:) if [ -z "${msg}" ]; then - msg="${component:+$component/}${refname}: ${author}: ${logmessage} [${ref}] ${url}" + msg="${component:+$component/}${refname}[${ref}]: ${author}: ${logmessage} [${url}]" else msg=$(echo "$msg" | sed -re 's,@@([^@]+)@@,${\1},g') eval "msg=\"$msg\"" fi +# trim $msg of empty []'s in case no URL was provided, might be better done in +# the above by making the generation conditional, but this will also do for +# now. +msg="${msg% []}" + ${sendmail} <<_eom ${from:+From: ${from} }To: ${to} ${cc:+Cc: ${cc} }Subject: Announce ${project} Message-Id: +Content-type: text/plain; charset=utf-8 ${msg} _eom