Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C26EC4338F for ; Sun, 1 Aug 2021 22:02:50 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4C6CD60F39 for ; Sun, 1 Aug 2021 22:02:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4C6CD60F39 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A9FC8832F6; Mon, 2 Aug 2021 00:02:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ni+v9Vak"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 903C2832F8; Mon, 2 Aug 2021 00:02:46 +0200 (CEST) Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 86D3B832DA for ; Mon, 2 Aug 2021 00:02:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oi1-x22a.google.com with SMTP id o185so21769796oih.13 for ; Sun, 01 Aug 2021 15:02:43 -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:mime-version :content-transfer-encoding; bh=bSDhkf5N3YOnP4fYPJJ28f2mGBP7KAHiK1vfxgMI6kw=; b=ni+v9VakvKK/MRQqL9rxUV65QH+fvPA32eCOeMvKNhpgbl8KnBGWECgQG8C8C6zsYu a4Ph7A4RyalpCXhzvyJNRZxOjDYvb/ylSjBi/tsnYeyCWmsh9JyBhZwWm/uL60NVZYPA kqhWrounerjNVnXGRJ1BLNqDAxGcmauhn1iqQ= 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:mime-version :content-transfer-encoding; bh=bSDhkf5N3YOnP4fYPJJ28f2mGBP7KAHiK1vfxgMI6kw=; b=ecxENx5lgeK6iEAsQCQ8PTcAUQnNbAykVGIJGT1iwVdgJQ2gLPvL13srZK+Tvc0ee8 tvFxG0hdv7HNfF7zT8l9kb8Wt2AtHKojwOKxgA9FPLrA7Y0IuNrxBKP5J55PVG4ss9MK q69hDt0nMzkZ/W5FvhQDspdN99G6cggGazsWAGauLUX4ptbknp++J/WrQzR6Rm6vHphK hpIY4aoua98FQOiBVv6PELsRaMpoOtzhC2NU1Vp3UOwdeY3fbdD2RVWMW+78w+g4gYrJ L++XZt+AAoCWUNAg5gwsXV4xKtKPexONWZy4EWF/ikypOHjGJt2m6pcP+rlBvEwFkNm0 ZyvA== X-Gm-Message-State: AOAM532nrAJIIzhuNB53FwgIzSjjt9BIuncKLMY25vHGKHMoWbF4sKDQ j3eYmoUSqS7rO5qUHGTC0KccfSW4DANrAjlP X-Google-Smtp-Source: ABdhPJxw0g4I3UFsTnnPulk952WzlPt3ES08TdFAmPkcrXhobMPfvU8aade9d6Gotb17WONSOk1+Xw== X-Received: by 2002:aca:aaca:: with SMTP id t193mr8406366oie.94.1627855361974; Sun, 01 Aug 2021 15:02:41 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id n12sm1222527oij.55.2021.08.01.15.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Aug 2021 15:02:41 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Simon Glass Subject: [PATCH] patman: Avoid blank lines between tags Date: Sun, 1 Aug 2021 16:02:39 -0600 Message-Id: <20210801220239.2224206-1-sjg@chromium.org> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean In some cases 'patman status' leaves a blank line between the sign-off and the tags it collects from patchwork. Fix this and add a test. Signed-off-by: Simon Glass --- tools/patman/func_test.py | 23 ++++++++++++++++++++++- tools/patman/patchstream.py | 7 ++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index 9871bb580d0..2493e527f52 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -136,7 +136,7 @@ class TestFunctional(unittest.TestCase): Commit-changes: 2 - Changes only for this commit - Cover-changes: 4 +' Cover-changes: 4 - Some notes for the cover letter Cover-letter: @@ -1293,3 +1293,24 @@ Reviewed-by: %s self.assertEqual(terminal.PrintLine( '4 new responses available in patchwork (use -d to write them to a new branch)', None), next(lines)) + + def testInsertTags(self): + """Test inserting of review tags""" + msg = '''first line +second line.''' + tags = [ + 'Reviewed-by: Bin Meng ', + 'Tested-by: Bin Meng ' + ] + signoff = 'Signed-off-by: Simon Glass ' + tag_str = '\n'.join(tags) + + new_msg = patchstream.insert_tags(msg, tags) + self.assertEqual(msg + '\n\n' + tag_str, new_msg) + + new_msg = patchstream.insert_tags(msg + '\n', tags) + self.assertEqual(msg + '\n\n' + tag_str, new_msg) + + msg += '\n\n' + signoff + new_msg = patchstream.insert_tags(msg, tags) + self.assertEqual(msg + '\n' + tag_str, new_msg) diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index b9602924273..2439fb18e42 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -662,6 +662,7 @@ def insert_tags(msg, tags_to_emit): out = [] done = False emit_tags = False + emit_blank = False for line in msg.splitlines(): if not done: signoff_match = RE_SIGNOFF.match(line) @@ -672,9 +673,13 @@ def insert_tags(msg, tags_to_emit): out += tags_to_emit emit_tags = False done = True + emit_blank = not (signoff_match or tag_match) + else: + emit_blank = line out.append(line) if not done: - out.append('') + if emit_blank: + out.append('') out += tags_to_emit return '\n'.join(out) -- 2.32.0.554.ge1b32706d8-goog