From patchwork Wed Aug 9 11:10:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Engestrom X-Patchwork-Id: 9890351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D23F860384 for ; Wed, 9 Aug 2017 11:13:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C87C628A57 for ; Wed, 9 Aug 2017 11:13:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD60B28A68; Wed, 9 Aug 2017 11:13:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8496F28A5B for ; Wed, 9 Aug 2017 11:13:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DCE686E2CF; Wed, 9 Aug 2017 11:13:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailapp01.imgtec.com (mailapp01.imgtec.com [195.59.15.196]) by gabe.freedesktop.org (Postfix) with ESMTP id 76AAD6E2C1; Wed, 9 Aug 2017 11:12:58 +0000 (UTC) Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Forcepoint Email with ESMTPS id 91DCBA714F1D4; Wed, 9 Aug 2017 12:12:54 +0100 (IST) Received: from localhost.localdomain (10.60.4.28) by HHMAIL01.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server (TLS) id 14.3.294.0; Wed, 9 Aug 2017 12:12:57 +0100 From: Eric Engestrom To: Subject: [maintainer-tools PATCH 3/7] dim: split out email parsing functions Date: Wed, 9 Aug 2017 12:10:57 +0100 Message-ID: <20170809111101.11315-3-eric.engestrom@imgtec.com> X-Mailer: git-send-email 2.14.0 In-Reply-To: <20170809111101.11315-1-eric.engestrom@imgtec.com> References: <20170809111101.11315-1-eric.engestrom@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [10.60.4.28] Cc: Jani Nikula , Daniel Vetter , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Eric Engestrom --- dim | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/dim b/dim index eaabcec43c8f..a656afa0d255 100755 --- a/dim +++ b/dim @@ -1958,6 +1958,16 @@ function dim_fixes fi } +function email_get_address +{ + sed -e 's/.*.*//' <<< "$1" +} + +function email_get_name +{ + echo ${cc/<*/} | sed -e 's/[[:space:]]*$//' <<< "$1" +} + function dim_add_missing_cc { if [ $(git cat-file -p HEAD | grep -cE ^parent) -ne 1 ]; then @@ -1966,11 +1976,11 @@ function dim_add_missing_cc fi git show | scripts/get_maintainer.pl --email --norolestats --pattern-depth 1 | while read cc; do - email="$(echo "$cc" | sed -e 's/.*.*//')" + email="$(email_get_address "$cc")" name='' if echo "$cc" | grep -q '<'; then - name="$(echo ${cc/<*/} | sed -e 's/[[:space:]]*$//')"; + name="$(email_get_name "$cc")"; fi # Don't add main mailing lists @@ -1983,12 +1993,12 @@ function dim_add_missing_cc # print out a 1 on success matches=$( git show -s | grep -i "^ Cc:" | sed 's/^ *[Cc][Cc]: *//' | while read testcc; do - testemail="$(echo "$testcc" | sed -e 's/.*.*//')" + testemail="$(email_get_address "$testcc")" if [ "$testemail" != "$email" ]; then if [ -z "$name" ]; then continue; fi - testname="$(echo ${testcc/<*/} | sed -e 's/[[:space:]]*$//' -e 's/^[[:space:]]*//')" + testname="$(email_get_name "$testcc" | sed -e 's/^[[:space:]]*//')" if [ "$testname" != "$name" ]; then continue; fi fi