summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-11-29 15:05:49 +0200
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-11-29 15:08:22 +0200
commit1a868fd09e1dc8e2a835923d3b2df9c4b036732d (patch)
tree46101155b6fc6883fa46233d8b2aff83495c0f02
parent2bc6d29ed5349b02d846d763338a1f87ff561115 (diff)
downloadaiaiai-1a868fd09e1dc8e2a835923d3b2df9c4b036732d.tar.gz
email-test-patchset: move compose_email to email-sh-functions
Move the 'compose_email' function to the shared file so that it could be used by other scripts. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
-rw-r--r--email/aiaiai-email-sh-functions43
-rwxr-xr-xemail/aiaiai-email-test-patchset44
2 files changed, 48 insertions, 39 deletions
diff --git a/email/aiaiai-email-sh-functions b/email/aiaiai-email-sh-functions
index dac176e..5005ef8 100644
--- a/email/aiaiai-email-sh-functions
+++ b/email/aiaiai-email-sh-functions
@@ -134,3 +134,46 @@ parse_prj_config()
cfg_always_cc="$(ini_config_get "$cfgfile" "prj_$prj" "always_cc")"
cfg_unwanted_keywords="$(ini_config_get "$cfgfile" ""prj_$prj"" "unwanted_keywords")"
}
+
+# Send an e-mail reply. This function assumes that the following variables are
+# defined: cfg_ownname, cfg_ownmail, cfg_adminname, cfg_adminmail,
+# cfg_preamble, cfg_signature. See 'parse_config()' function.
+#
+# Usage: compose_email <to> <cc1> <cc2> <subj> <in_reply_to> <tmpfile>
+#
+# The "tmpfile" parameter is a file where this function will store a copy of
+# the send e-mail.
+compose_email()
+{
+ local to="$1"; shift
+ local cc1="$1"; shift
+ local cc2="$1"; shift
+ local subj="$1"; shift
+ local in_reply_to="$1"; shift
+ local tmpfile="$1"; shift
+
+
+ cat > "$tmpfile" <<EOF
+To: $to
+From: "$cfg_ownname" <$cfg_ownmail>
+Cc: $cfg_always_cc
+Cc: $cc1
+Cc: $cc2
+Subject: Re: $subj
+In-Reply-To: $in_reply_to
+Reply-To: "$cfg_adminname" <$cfg_adminmail>
+
+$cfg_preamble
+
+$(cat)
+
+--
+$cfg_signature
+EOF
+
+ [ -z "$verbose" ] || cat -- "$tmpfile" >&2
+ [ -z "$test_mode" ] &&
+ mutt -x -H "$tmpdir/mail" </dev/null ||
+ verbose "Do not actually send the email - we are in test mode"
+}
+
diff --git a/email/aiaiai-email-test-patchset b/email/aiaiai-email-test-patchset
index a56e7e9..6c09af1 100755
--- a/email/aiaiai-email-test-patchset
+++ b/email/aiaiai-email-test-patchset
@@ -70,34 +70,6 @@ cleanup_handler()
}
set_cleanup_handler cleanup_handler
-# Send a reply to the author of the patch, the contents of the reply has to
-# come from stdin
-compose_email()
-{
- cat > "$tmpdir/mail" <<EOF
-To: $from
-From: "$cfg_ownname" <$cfg_ownmail>
-Cc: $cfg_always_cc
-Cc: $to
-Cc: $cc
-Subject: Re: $subj
-In-Reply-To: $id
-Reply-To: "$cfg_adminname" <$cfg_adminmail>
-
-$cfg_preamble
-
-$(cat)
-
---
-$cfg_signature
-EOF
-
- [ -z "$verbose" ] || cat -- "$tmpdir/mail" >&2
- [ -z "$test_mode" ] &&
- mutt -x -H "$tmpdir/mail" </dev/null ||
- verbose "Do not actually send the email - we are in test mode"
-}
-
# List projects currently supported
list_projects()
{
@@ -228,10 +200,7 @@ cc=$(strip_address "$cc")
# Reject the e-mail if the project has not been specified
if [ -z "$prj" ]; then
- to=
- cc=
- cfg_always_cc=
- compose_email <<EOF
+ compose_email "$from" "" "" "$subj" "$id" "$tmpdir/mail" <<EOF
Sorry, but you have not specified the project name. Please, specify it
using symbol "+" in the e-mail address of $ownname.
@@ -249,10 +218,7 @@ parse_prj_config "$cfgfile" "$prj"
# Check if we have this project in our config file
if [ -z "$cfg_name" ]; then
- to=
- cc=
- cfg_always_cc=
- compose_email <<EOF
+ compose_email "$from" "" "" "$subj" "$id" "$tmpdir/mail" <<EOF
Sorry, but project "$prj" is not supported. List of projects $cfg_ownname supports:
$(list_projects)
@@ -270,7 +236,7 @@ fi
# Notify the sender that the patches have been accepted
if [ "$cfg_accept_notify" = "1" ]; then
message "Sending \"accepted\" e-mail"
- compose_email <<EOF
+ compose_email "$from" "$to" "$cc" "$subj" "$id" "$tmpdir/mail" <<EOF
Your patch or patch-set:
$(fetch_header_per_patch "Subject" < "$mbox" | sort)
@@ -288,7 +254,7 @@ aiaiai-test-patchset $verbose $preserve $bisectability $sparse $smatch $cppcheck
"$cfg_path" "$cfg_configs" > "$tmpdir/test-patchset.log" ||
{
message "aiaiai-test-patchset failed"
- compose_email <<EOF
+ compose_email "$from" "$to" "$cc" "$subj" "$id" "$tmpdir/mail" <<EOF
Sorry, but an internal error happened. Please, send a bug report to
"$cfg_adminname" <$cfg_adminmail>.
EOF
@@ -297,7 +263,7 @@ EOF
message "Test is finished, sending back the results"
-compose_email <<EOF
+compose_email "$from" "$to" "$cc" "$subj" "$id" "$tmpdir/mail" <<EOF
$cfg_built_preamble
$(fetch_header_per_patch "Subject" < "$mbox" | sort)