DPDK CI discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: ci@dpdk.org
Subject: [dpdk-ci] [PATCH v5 6/9] tools: add patch mail download
Date: Thu, 15 Dec 2016 00:05:20 +0100	[thread overview]
Message-ID: <1481756723-4868-7-git-send-email-thomas.monjalon@6wind.com> (raw)
In-Reply-To: <1481756723-4868-1-git-send-email-thomas.monjalon@6wind.com>

This script downloads a patch from patchwork with some email headers.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
 tools/{parse-email.sh => download-patch.sh} | 43 +++++++++++++----------------
 tools/parse-email.sh                        |  2 ++
 2 files changed, 21 insertions(+), 24 deletions(-)
 copy tools/{parse-email.sh => download-patch.sh} (73%)

diff --git a/tools/parse-email.sh b/tools/download-patch.sh
similarity index 73%
copy from tools/parse-email.sh
copy to tools/download-patch.sh
index d92c246..86d08c2 100755
--- a/tools/parse-email.sh
+++ b/tools/download-patch.sh
@@ -32,41 +32,36 @@
 
 print_usage () {
 	cat <<- END_OF_HELP
-	usage: $(basename $0) <email_file>
+	usage: $(basename $0) [-g] <patchwork_id>
 
-	Parse basic headers of the email
-	and print them as shell variable assignments to evaluate.
+	Download a patch from patchwork through pwclient XML-RPC (default)
+	or curl HTTP GET (option -g).
 	END_OF_HELP
 }
 
-while getopts h arg ; do
+. $(dirname $(readlink -e $0))/load-ci-config.sh
+pwclient=${DPDK_CI_PWCLIENT:-$(dirname $(readlink -m $0))/pwclient}
+
+http_get=false
+while getopts gh arg ; do
 	case $arg in
+		g ) http_get=true ;;
 		h ) print_usage ; exit 0 ;;
 		? ) print_usage >&2 ; exit 1 ;;
 	esac
 done
 shift $(($OPTIND - 1))
-if [ -z "$1" ] ; then
-	printf 'file argument is missing\n\n' >&2
+pwid=$1
+if [ -z "$pwid" ] ; then
+	printf 'missing argument\n\n' >&2
 	print_usage >&2
 	exit 1
 fi
 
-getheader () # <header_name> <email_file>
-{
-	sed "/^$1: */!d;s///;N;s,\n[[:space:]]\+, ,;s,\n.*,,;q" "$2" |
-	sed 's,",\\",g'
-}
-
-subject=$(getheader Subject "$1")
-from=$(getheader From "$1")
-msgid=$(getheader Message-Id "$1")
-[ -n "$msgid" ] || msgid=$(getheader Message-ID "$1")
-listid=$(getheader List-Id "$1")
-
-cat <<- END_OF_HEADERS
-	subject="$subject"
-	from="$from"
-	msgid="$msgid"
-	listid="$listid"
-END_OF_HEADERS
+if $http_get ; then
+	url="http://dpdk.org/dev/patchwork/patch/$pwid/mbox/"
+	curl -sf $url
+else
+	$pwclient view $pwid
+fi |
+sed '/^Subject:/{s/\(\[[^],]*\)/\1] [PATCH/;s/,/ /g}'
diff --git a/tools/parse-email.sh b/tools/parse-email.sh
index d92c246..d997f5e 100755
--- a/tools/parse-email.sh
+++ b/tools/parse-email.sh
@@ -62,11 +62,13 @@ subject=$(getheader Subject "$1")
 from=$(getheader From "$1")
 msgid=$(getheader Message-Id "$1")
 [ -n "$msgid" ] || msgid=$(getheader Message-ID "$1")
+pwid=$(getheader X-Patchwork-Id "$1")
 listid=$(getheader List-Id "$1")
 
 cat <<- END_OF_HEADERS
 	subject="$subject"
 	from="$from"
 	msgid="$msgid"
+	pwid="$pwid"
 	listid="$listid"
 END_OF_HEADERS
-- 
2.7.0

  parent reply	other threads:[~2016-12-14 23:05 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-25 17:02 [dpdk-ci] [PATCH 0/7] first scripts for CI integration Thomas Monjalon
2016-11-25 17:02 ` [dpdk-ci] [PATCH 1/7] tools: add mail filter Thomas Monjalon
2016-11-25 17:02 ` [dpdk-ci] [PATCH 2/7] tools: add mail parser Thomas Monjalon
2016-11-25 17:02 ` [dpdk-ci] [PATCH 3/7] config: add loader and template Thomas Monjalon
2016-11-25 17:02 ` [dpdk-ci] [PATCH 4/7] tools: add patchwork client Thomas Monjalon
2016-11-25 17:02 ` [dpdk-ci] [PATCH 5/7] tools: add per-patch report mailer Thomas Monjalon
2016-11-25 17:02 ` [dpdk-ci] [PATCH 6/7] tools: add patchwork integration Thomas Monjalon
2016-11-25 17:02 ` [dpdk-ci] [PATCH 7/7] tests: add checkpatch Thomas Monjalon
2016-12-01 13:44 ` [dpdk-ci] [PATCH v2 0/7] first scripts for CI integration Thomas Monjalon
2016-12-01 13:44   ` [dpdk-ci] [PATCH v2 1/7] tools: add mail filter Thomas Monjalon
2016-12-01 13:44   ` [dpdk-ci] [PATCH v2 2/7] tools: add mail parser Thomas Monjalon
2016-12-01 13:44   ` [dpdk-ci] [PATCH v2 3/7] config: add loader and template Thomas Monjalon
2016-12-01 13:44   ` [dpdk-ci] [PATCH v2 4/7] tools: add patchwork client Thomas Monjalon
2016-12-01 13:44   ` [dpdk-ci] [PATCH v2 5/7] tools: add per-patch report mailer Thomas Monjalon
2016-12-01 13:44   ` [dpdk-ci] [PATCH v2 6/7] tools: add patchwork integration Thomas Monjalon
2016-12-01 13:44   ` [dpdk-ci] [PATCH v2 7/7] tests: add checkpatch Thomas Monjalon
2016-12-01 16:58   ` [dpdk-ci] [PATCH v3 0/7] first scripts for CI integration Thomas Monjalon
2016-12-01 16:58     ` [dpdk-ci] [PATCH v3 1/7] tools: add mail filter Thomas Monjalon
2016-12-01 16:58     ` [dpdk-ci] [PATCH v3 2/7] tools: add mail parser Thomas Monjalon
2016-12-01 16:58     ` [dpdk-ci] [PATCH v3 3/7] config: add loader and template Thomas Monjalon
2016-12-01 16:58     ` [dpdk-ci] [PATCH v3 4/7] tools: add patchwork client Thomas Monjalon
2016-12-01 16:58     ` [dpdk-ci] [PATCH v3 5/7] tools: add per-patch report mailer Thomas Monjalon
2016-12-01 16:59     ` [dpdk-ci] [PATCH v3 6/7] tools: add patchwork integration Thomas Monjalon
2016-12-01 16:59     ` [dpdk-ci] [PATCH v3 7/7] tests: add checkpatch Thomas Monjalon
2016-12-05 13:26   ` [dpdk-ci] [PATCH v4 0/7] first scripts for CI integration Thomas Monjalon
2016-12-05 13:26     ` [dpdk-ci] [PATCH v4 1/7] tools: add mail filter Thomas Monjalon
2016-12-05 13:26     ` [dpdk-ci] [PATCH v4 2/7] tools: add mail parser Thomas Monjalon
2016-12-05 13:26     ` [dpdk-ci] [PATCH v4 3/7] config: add loader and template Thomas Monjalon
2016-12-05 13:26     ` [dpdk-ci] [PATCH v4 4/7] tools: add patchwork client Thomas Monjalon
2016-12-05 13:26     ` [dpdk-ci] [PATCH v4 5/7] tools: add per-patch report mailer Thomas Monjalon
2016-12-05 13:26     ` [dpdk-ci] [PATCH v4 6/7] tools: add patchwork integration Thomas Monjalon
2016-12-05 13:26     ` [dpdk-ci] [PATCH v4 7/7] tests: add checkpatch Thomas Monjalon
2016-12-06  6:34       ` Wei, FangfangX
2016-12-06  8:40         ` Thomas Monjalon
2016-12-06  9:04           ` Wei, FangfangX
2016-12-07  5:48           ` Wei, FangfangX
2016-12-07  9:32             ` Thomas Monjalon
2016-12-08  9:02               ` Wei, FangfangX
2016-12-08 13:11                 ` Thomas Monjalon
2016-12-09  8:51                   ` Wei, FangfangX
2016-12-09  9:16                     ` Thomas Monjalon
2016-12-09 10:07                       ` Mcnamara, John
2016-12-09 10:11                         ` Thomas Monjalon
2016-12-09 12:11                           ` Mcnamara, John
2016-12-12  9:27                       ` Wei, FangfangX
2016-12-12  9:34                         ` Wei, FangfangX
2016-12-12  9:58                           ` Thomas Monjalon
2016-12-13  8:29                             ` Wei, FangfangX
2016-12-13  8:49                               ` Thomas Monjalon
2016-12-13  9:24                                 ` Wei, FangfangX
2016-12-21 11:45                                   ` Thomas Monjalon
2016-12-12  9:39                         ` Thomas Monjalon
2016-12-13  8:22                           ` Wei, FangfangX
2016-12-14 23:05     ` [dpdk-ci] [PATCH v5 0/9] first scripts for CI integration Thomas Monjalon
2016-12-14 23:05       ` [dpdk-ci] [PATCH v5 1/9] tools: add mail filter Thomas Monjalon
2016-12-14 23:05       ` [dpdk-ci] [PATCH v5 2/9] tools: add mail parser Thomas Monjalon
2016-12-14 23:05       ` [dpdk-ci] [PATCH v5 3/9] config: add loader and template Thomas Monjalon
2016-12-14 23:05       ` [dpdk-ci] [PATCH v5 4/9] tools: add patchwork client Thomas Monjalon
2016-12-14 23:05       ` [dpdk-ci] [PATCH v5 5/9] tools: fix pwclient for proxy and python 3 Thomas Monjalon
2016-12-14 23:05       ` Thomas Monjalon [this message]
2016-12-14 23:05       ` [dpdk-ci] [PATCH v5 7/9] tools: add per-patch report mailer Thomas Monjalon
2016-12-14 23:05       ` [dpdk-ci] [PATCH v5 8/9] tools: add patchwork integration Thomas Monjalon
2016-12-14 23:05       ` [dpdk-ci] [PATCH v5 9/9] tests: add checkpatch Thomas Monjalon
2016-12-21 11:46       ` [dpdk-ci] [PATCH v5 0/9] first scripts for CI integration Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1481756723-4868-7-git-send-email-thomas.monjalon@6wind.com \
    --to=thomas.monjalon@6wind.com \
    --cc=ci@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).