[PATCH RFC 3/4] aiaiai: add initial support for dispatcher hook

Jacob Keller jacob.e.keller at intel.com
Fri Mar 14 17:16:00 PDT 2014

This patch adds some initial support for a dispatcher hook which could
be used to add custom headers, which will (later) be interpreted by
aiaiai to include specialized settings. A follow-on patch will add the
first initial custom header.

Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
 doc/email/CONFIGURATION              | 31 +++++++++++++++++++++++++++++++
 doc/email/example-aiaiai.cfg         |  7 +++++++
 email/aiaiai-email-dispatcher-helper | 10 ++++++++++
 email/aiaiai-email-sh-functions      |  3 +++
 4 files changed, 51 insertions(+)

diff --git a/doc/email/CONFIGURATION b/doc/email/CONFIGURATION
index 7e7af5b4c396..e4a7e0353be2 100644
--- a/doc/email/CONFIGURATION
+++ b/doc/email/CONFIGURATION
@@ -156,3 +156,34 @@ specified for each project.
     to make this a bare remote or a local tree. Generally, aiaiai works best if
     the tree is locally stored on the same machine as the aiaiai process.
+2.4 Aiaiai Hooks
+The [hooks] section can be used to specify scripts which are called by various
+aiaiai tools, and can be used to customize the behavior of aiaiai. This is
+generally done by modifying the mbox to include custom headers, which are
+detailed below.
+The two following headers are generally inserted by aiaiai-email-lda and most
+likely don't need to be inserted by a hook, but are included here for
+* X-Aiaiai-Cover-Letter-Subject
+    This is the subject of the 0/n email if one is given when sending a patch
+    series.
+* X-Aiaiai-Cover-Letter-Message-Id
+    This is the message Id of the 0/n email if one was given when sending a
+    patch series.
+The above two settings are used by aiaiai-email-test-patchset so that it can
+formulate a reply to the 0/n email instead of replying to the 1/n email of a
+patch series. This helps indicate that the entire patch series was validated,
+instead of appearing as though only the first patch was tested.
+2.4.1 Dispatcher Hook
+The dispatcher hook is called by aiaiai-email-dispatcher-helper, and receives
+the mbox file as its first argument, and the cfgfile as its second argument. It
+should modify the mbox file inplace, to include any custom headers specified
diff --git a/doc/email/example-aiaiai.cfg b/doc/email/example-aiaiai.cfg
index e41c36143137..6101c5824fc6 100644
--- a/doc/email/example-aiaiai.cfg
+++ b/doc/email/example-aiaiai.cfg
@@ -44,6 +44,13 @@
 	# aiaiai will insert it for you.
 	built_preamble = I have tested your changes
+	# A hook called by aiaiai-email-dispatcher-helper, which should insert
+	# custom headers into the mbox file. Specific documentation on this is
+	# provided in the doc/email section, including expected argument
+	# format, as well as what headers are recognized by other tools.
+	dispatcher =
 # These options are probably not useful, but may help debug issues with aiaiai
 	# Set to (1) to disable sending reply emails when a patch is tested.
diff --git a/email/aiaiai-email-dispatcher-helper b/email/aiaiai-email-dispatcher-helper
index 70d1025244f0..018c0d4cdc9b 100755
--- a/email/aiaiai-email-dispatcher-helper
+++ b/email/aiaiai-email-dispatcher-helper
@@ -90,8 +90,18 @@ fail_file="$1"; shift
 queuedir="$(readlink -fv -- "$1")"; shift
 cfgfile="$1"; shift
+# Parse the configuration file
+parse_config "$cfgfile"
 tmpdir="$(mktemp -dt "$PROG.XXXX")"
+# Run the dispatcher hook
+if [ -n "$cfg_dispatch_hook" ]; then
+	hook="$(readlink -fv -- "$cfg_dispatch_hook")"
+	verbose "Running \"$hook\" on \"$mbox\""
+	$hook "$mbox" "$cfgfile"
 verbose "Validating \"$mbox\", queue directory is: $queuedir"
 verbose "Configuration file: $cfgfile"
diff --git a/email/aiaiai-email-sh-functions b/email/aiaiai-email-sh-functions
index 440e358daff9..f996e9db4a46 100644
--- a/email/aiaiai-email-sh-functions
+++ b/email/aiaiai-email-sh-functions
@@ -163,6 +163,9 @@ parse_config()
 	ini_config_get_or_die cfg_signature      "$cfgfile" "global" "signature"
 	ini_config_get_or_die cfg_built_preamble "$cfgfile" "global" "built_preamble"
+	# Hooks which can be used to enable custom behavior
+	cfg_dispatch_hook="$(ini_config_get "$cfgfile" "hooks" "dispatcher")"
 	# Debug options
 	cfg_disable_notifications="$(ini_config_get "$cfgfile" "debug" "disable_notifications")"
 	cfg_preserve_files="$(ini_config_get "$cfgfile" "debug" "preserve_files")"

More information about the aiaiai mailing list