From patchwork Wed Aug 9 11:11:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Engestrom X-Patchwork-Id: 9890349 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 106FA60384 for ; Wed, 9 Aug 2017 11:13:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 069DA28A51 for ; Wed, 9 Aug 2017 11:13:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFAE528A61; Wed, 9 Aug 2017 11:13:07 +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 ABF8328A51 for ; Wed, 9 Aug 2017 11:13:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DF9836E2D1; 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 6F46D6E2CA; Wed, 9 Aug 2017 11:13:00 +0000 (UTC) Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Forcepoint Email with ESMTPS id 8AEB8E386AE97; Wed, 9 Aug 2017 12:12:56 +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:59 +0100 From: Eric Engestrom To: Subject: [maintainer-tools PATCH 6/7] dim: split out 'is email cc'ed in latest commit' to a function Date: Wed, 9 Aug 2017 12:11:00 +0100 Message-ID: <20170809111101.11315-6-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 | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/dim b/dim index 481a53e23035..2e22fefa8867 100755 --- a/dim +++ b/dim @@ -1970,6 +1970,31 @@ function email_get_name fi } +function email_cc_in_latest_commit +{ + email="$1" + name="$2" + + git show -s | grep -i "^ Cc:" | sed 's/^ *[Cc][Cc]: *//' | while read -r testcc; do + testemail="$(email_get_address "$testcc")" + testname="$(email_get_name "$testcc" | sed -e 's/^[[:space:]]*//')" + + if [ "$testemail" = "$email" ]; then + return 1 + fi + + if [ -z "$testname" ] || [ -z "$name" ]; then + continue + fi + + if [ "$testname" = "$name" ]; then + return 1 + fi + done || return 0 + + return 1 +} + function dim_add_missing_cc { if [ $(git cat-file -p HEAD | grep -cE ^parent) -ne 1 ]; then @@ -1987,26 +2012,7 @@ function dim_add_missing_cc continue fi - # Variables from the while loop don't propagate, - # print out a 1 on success - matches=$( - git show -s | grep -i "^ Cc:" | sed 's/^ *[Cc][Cc]: *//' | while read testcc; do - testemail="$(email_get_address "$testcc")" - - if [ "$testemail" != "$email" ]; then - if [ -z "$name" ]; then continue; fi - - testname="$(email_get_name "$testcc" | sed -e 's/^[[:space:]]*//')" - - if [ "$testname" != "$name" ]; then continue; fi - fi - - echo 1 - break - done - ) - - if [ -z "$matches" ]; then + if ! email_cc_in_latest_commit "$email" "$name"; then $DRY dim_commit_add_tag "Cc: ${cc}" fi done