summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Keller <jacob.e.keller@intel.com>2014-03-14 17:16:00 -0700
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2014-03-18 15:35:17 +0200
commita287fcad9b13482e8dc245842f44270d5121fbce (patch)
tree8e42d25e9f2c34fae9ae35534867510e237fe1dd
parent2fd02fa2933a106e7e6d7ca8f5f77fd6f2ef3d57 (diff)
downloadaiaiai-a287fcad9b13482e8dc245842f44270d5121fbce.tar.gz
aiaiai: add initial support for dispatcher hook
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@intel.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
-rw-r--r--doc/email/CONFIGURATION31
-rw-r--r--doc/email/example-aiaiai.cfg7
-rwxr-xr-xemail/aiaiai-email-dispatcher-helper10
-rw-r--r--email/aiaiai-email-sh-functions3
4 files changed, 51 insertions, 0 deletions
diff --git a/doc/email/CONFIGURATION b/doc/email/CONFIGURATION
index 7e7af5b..e4a7e03 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
+completeness.
+
+* 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
+above.
diff --git a/doc/email/example-aiaiai.cfg b/doc/email/example-aiaiai.cfg
index e41c361..6101c58 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
+[hooks]
+ # 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
[debug]
# 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 70d1025..018c0d4 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"
+fi
+
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 440e358..f996e9d 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")"