From patchwork Fri Apr 14 16:43:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9681425 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 819B760386 for ; Fri, 14 Apr 2017 16:43:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 738F4205AF for ; Fri, 14 Apr 2017 16:43:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 684E7286CD; Fri, 14 Apr 2017 16:43:19 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 D9CE8205AF for ; Fri, 14 Apr 2017 16:43:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A5886E9D8; Fri, 14 Apr 2017 16:43:18 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qk0-x22b.google.com (mail-qk0-x22b.google.com [IPv6:2607:f8b0:400d:c09::22b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F3916E9E3 for ; Fri, 14 Apr 2017 16:43:16 +0000 (UTC) Received: by mail-qk0-x22b.google.com with SMTP id f133so71094291qke.2 for ; Fri, 14 Apr 2017 09:43:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MobFMUlmRT+Ep8szz8QAOP2CpYoPU+VU2e1gX7p1SS0=; b=BJKUHDyXvcc8sOJTXk0ECa0wugMA9ovJt6G4+HLTQSG8qd3vNgFwIEuvF3NF9bi6qb Cw+wYvRifSoCnbbVzpCpidt2OpTohY9RtQpDMGfD4We2jlU0Xucp3HQAJ1yLbNzUpnRs dDVDqItB3kFcXruW9ar2gbTzRef5gVg3Yp5I8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MobFMUlmRT+Ep8szz8QAOP2CpYoPU+VU2e1gX7p1SS0=; b=hVmIyv6iEzGkeDm0Fx8Ksq15tswnkteKI6tW/dDvLlJvvdi7krtxM543ZuIHmaB+Iu bfUD6RWC9bh+HBut3Nq5ByHDpjyK0pF74SRjjrgZfrLl2Yti/Srr0h7NByU6eDYZwYk7 UM7qQIJVjt1xRlofZ42CtEhPLAudc4WO+cKWVaX1b+P6KfMAzJUM3R36P4n6SksnWuy6 WKyEoN0CRm3auacKG7gyaRdEaEqd2RrixpFhNHCtGM84FUZsC84EAiKRBnYwpsvDtPt7 yxoHmaJcsRJLUTYTyKyYHe7Y69YJyZwkrdj+xDQeDUcSgBNsL6oLIjUDy3gmNuVt/KAm Ttwg== X-Gm-Message-State: AN3rC/7o8F9dsYPcDeZYi9yM4HMtw+tk2Byo4Mk2SImP9x/J16+7OOE6 k0U/eo9EqV2uR//k X-Received: by 10.55.149.130 with SMTP id x124mr5170016qkd.99.1492188195293; Fri, 14 Apr 2017 09:43:15 -0700 (PDT) Received: from localhost.localdomain (99-45-70-16.lightspeed.rlghnc.sbcglobal.net. [99.45.70.16]) by smtp.gmail.com with ESMTPSA id p19sm1530561qtp.36.2017.04.14.09.43.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Apr 2017 09:43:14 -0700 (PDT) From: Sean Paul To: intel-gfx@lists.freedesktop.org, ville.syrjala@linux.intel.com, jani.nikula@linux.intel.com Date: Fri, 14 Apr 2017 12:43:13 -0400 Message-Id: <20170414164313.36222-1-seanpaul@chromium.org> X-Mailer: git-send-email 2.12.2.762.g0e3151a226-goog In-Reply-To: <878tndzre0.fsf@intel.com> References: <878tndzre0.fsf@intel.com> Subject: [Intel-gfx] [maintainer-tools PATCH v3 2/2] dim: Curate and insert tags into patch(es) X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Launch $EDITOR when extracting tags to curate the tags immediately. Once the tags are proper, automatically add them before the committer's Signed-off-by line to all patches in the range. Changes in v2: - Append the tags before the committer's SoB (Ville) - Make launching $EDITOR contingent on -i flag (Ville/Jani) - Fix tty issues when launching editor Changes in v3: - Don't overload interactive mode (add new edit mode) (Jani) - Don't default to vi, use non-edit mode if EDITOR not set (Jani) - Fix newline escaping in insert_extracted_tags Signed-off-by: Sean Paul --- dim | 49 +++++++++++++++++++++++++++++++++++++++---------- dim.rst | 5 +++++ 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/dim b/dim index 750f737..d791df3 100755 --- a/dim +++ b/dim @@ -144,13 +144,17 @@ INTERACTIVE= DRY= FORCE= HELP= +EDIT= -while getopts hdfis opt; do +while getopts hdefis opt; do case "$opt" in d) DRY_RUN=--dry-run DRY=echo ;; + e) + EDIT=1 + ;; f) FORCE=1 ;; @@ -670,13 +674,23 @@ function dim_push_fixes dim_push_branch drm-intel-fixes "$@" } +function get_committer_email +{ + local committer_email + + if ! committer_email=$(git config --get user.email) ; then + committer_email=$EMAIL + fi + echo -n $committer_email +} + # ensure we're on branch $1, and apply patches. the rest of the arguments are # passed to git am. dim_alias_ab=apply-branch dim_alias_sob=apply-branch function dim_apply_branch { - local branch file message_id commiter_email patch_from sob rv + local branch file message_id committer_email patch_from sob rv branch=${1:?$usage} shift @@ -688,13 +702,10 @@ function dim_apply_branch cat > $file message_id=$(message_get_id $file) - - if ! commiter_email=$(git config --get user.email) ; then - commiter_email=$EMAIL - fi + committer_email=$(get_committer_email) patch_from=$(grep "From:" "$file" | head -1) - if [[ "$patch_from" != *"$commiter_email"* ]] ; then + if [[ "$patch_from" != *"$committer_email"* ]] ; then sob=-s fi @@ -1213,6 +1224,15 @@ function rangeish() fi } +function insert_extracted_tags +{ + local committer_email new_tags sob + committer_email=$(get_committer_email) + new_tags=$(awk '{ORS="\\n"} {print $0}' $1 | head -c-3) + sob="Signed-off-by: .*<$committer_email>" + awk "/$sob/{p++} p==1{print \"$new_tags\"; p++} p!=1{print}" +} + function dim_extract_tags { local branch range file tags @@ -1234,9 +1254,18 @@ function dim_extract_tags return 0 fi - tags=$(printf -- "# *** extracted tags ***\n%s" "$tags") - - git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range + # If edit is selected, launch an editor to allow tag editing + # If it's not, just append the tags at the bottom of the commit + if [ "$EDIT" ] && [ -n $EDITOR ]; then + echo "$tags" > $file + $EDITOR $file >/dev/tty