X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=message_helper;h=d13360a7a22f02e818af672d9779e1f7923228ac;hb=HEAD;hp=bd7c1106a69cd9c03b46cfc5a5e61b87ddd8d428;hpb=a05e27f1805f6fe3c35a0c60aadc3d2b1b054014;p=next-scripts diff --git a/message_helper b/message_helper index bd7c110..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 Mailing List , Linux Kernel Mailing List " - -[ "$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