X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=message_helper;h=d13360a7a22f02e818af672d9779e1f7923228ac;hb=HEAD;hp=a181ef6fe9f15f1818680c363874eb1763b882f1;hpb=7fc728705df723b3dfc59f66dd9d81d6bae97aa2;p=next-scripts diff --git a/message_helper b/message_helper index a181ef6..d13360a 100755 --- a/message_helper +++ b/message_helper @@ -1,46 +1,47 @@ #!/bin/bash -. "$(dirname $0)/common.sh" "" +# shellcheck source=./common.sh +. "$(dirname "$0")/common.sh" '' -log=$LOG_FILE -[ -f merge.log ] && log=merge.log -control=$CTRL_FILE -[ -f control ] && control=control +log="$LOG_FILE" +if [ -f merge.log ]; then + log='merge.log' +fi -branch="" -[ "$1" = "-t" ] && { - branch=$2 +branch= +if [ "$1" = '-b' ]; then + branch="$2" shift 2 -} +fi -kconfig="" -[ "$1" = "-c" ] && { - kconfig=$2 +kconfig= +if [ "$1" = '-c' ]; then + kconfig="$2" shift 2 -} - -cc="linux-next@vger.kernel.org, linux-kernel@vger.kernel.org" - -[ "$branch" ] || { - branch=$(grep '^Merging ' $log | tail -1 | sed 's/^Merging //' | sed 's/ .*$//') - branch=${branch%%/*} -} - -contact=$(awk -F ' ' '$3=="'"$branch"'" { print $1; }' $control) -greeting=${contact%% *} -greeting=${greeting#\"} -[ "${contact%,*}" = "${contact}" ] || greeting="all" - -subject="${1//BRANCH/$branch}" -filter="sed -e \"s/BRANCH/$branch/g\"" -[ "$kconfig" ] && - filter="$filter -e \"s/KCONFIG_NAME/$kconfig/g\"" -filter="$filter | fmt -s" - -$(dirname $0)/send_email "$contact" "$cc" "linux-next: $subject" <' + 'Linux Kernel Mailing List ' + "$@" ) + +if [ -z "$branch" ]; then + branch=$(grep '^Merging ' "$log" | tail -n 1 | + sed 's/^Merging \([^ /]*\).*$/\1/') +fi + +contact=$(get_contacts "$branch") +subject=${subject//BRANCH/$branch} +filter=( -E -e 's/^([^ ])/|\1/' -e "s/BRANCH/$branch/g" ) +if [ -n "$kconfig" ]; then + filter+=( -e "s/KCONFIG_NAME/$kconfig/g" ) +fi + +{ + printf 'Hi all,\n\n' + sed "${filter[@]}" | fmt -w 76 -u -p '|' | sed 's/^|//' +} | "$bin_dir"/send_email "linux-next: $subject" "$contact" "${cc[@]}" exit 0