From patchwork Mon Oct 26 01:04:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1387380 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=e1Gq+4Xo; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CKGvG34wWz9sT6 for ; Mon, 26 Oct 2020 12:09:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6925C82537; Mon, 26 Oct 2020 02:06:03 +0100 (CET) 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="e1Gq+4Xo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 991E3824CC; Mon, 26 Oct 2020 02:05:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE, T_FILL_THIS_FORM_SHORT,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) (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 AD195824C3 for ; Mon, 26 Oct 2020 02:05:21 +0100 (CET) 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-io1-xd29.google.com with SMTP id y20so8383951iod.5 for ; Sun, 25 Oct 2020 18:05:21 -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 :mime-version:content-transfer-encoding; bh=ccZf0tjgnk+HGtaypXboBAmv7yO9uHFHZQCLZ3fWAYk=; b=e1Gq+4XodGuZYRNQ3MaShonFlPkhFRHMuphags83aRzQtUtkAdpHGfu2so6YWzWwnt yiax/lfm+e05IauA6/of/g+HzgNBfyO3HgI9h02Ejmj4tk531c7LhBPskIinAZbwoTwM zLZtNGGXCysu/IcfiZkwSCxqgRXNQr8XbFBhc= 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:mime-version:content-transfer-encoding; bh=ccZf0tjgnk+HGtaypXboBAmv7yO9uHFHZQCLZ3fWAYk=; b=lqAn9WWr1OjSvgdt0slaJqSYi9sSTVskaktrkpb/9Iho7rGLhZwwaLy0zHI926ghRU oxspMlW3GDLXCT8KYkx273Ss80zzYiu3PBIJJXZl/mEj6FTaMFXRRc7TYkCxK9tGJb7U rIDKKlrIEEW7ExOh6x1fhO/KBYVVtIuWhGm3Y22pwrJ6zwf58YsPSH/QAWSxOokOaeQu ekLJ6xuDewkrCTPqTr2SVBBsLx4sDJxLDbvAzIZuYZgPKue9UAsnJpY4I8pa7v5CaIuN EBSP++V+y/o6Cn2SsHh9rCUse5JBzTMSp01GgH2auNfOeLs2oxYBDUkp1Bv+WvIOfuvK jQVQ== X-Gm-Message-State: AOAM532BlOVtMpxt4bKqdy9cFIo5rc0ls2MvBxQO1lzmwk7cDM70rqHw JlpMIVGZAWrY751VTQb3gb3X6M964prmbxNe X-Google-Smtp-Source: ABdhPJzu33WRTlRSvCgbdh0Gjqkuk/9pKjvzgk5S2/QJoAJebNx9agzIj2LCOyxZJIsEw/01VvEcOQ== X-Received: by 2002:a05:6638:45:: with SMTP id a5mr8258914jap.102.1603674320245; Sun, 25 Oct 2020 18:05:20 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id a6sm5231162ili.11.2020.10.25.18.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2020 18:05:19 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Doug Anderson , patchwork@lists.ozlabs.org, Simon Glass , Sean Anderson Subject: [PATCH v2 21/30] patman: Require tags to be before sign-off Date: Sun, 25 Oct 2020 19:04:33 -0600 Message-Id: <20201026010442.1606893-22-sjg@chromium.org> X-Mailer: git-send-email 2.29.0.rc2.309.g374f81d7ae-goog In-Reply-To: <20201026010442.1606893-1-sjg@chromium.org> References: <20201026010442.1606893-1-sjg@chromium.org> MIME-Version: 1.0 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.102.3 at phobos.denx.de X-Virus-Status: Clean At present it is possible to put sign-off tags before the change log. This works but then it is hard for patman to add its own tags to a commit. Also if the commit has a Change-Id (e.g. for Gerrit) the commit becomes invalid if there is anything after it. Report a warning if patman tags are in the wrong place. One test patch already has the sign-off in the wrong place. Update the second one to avoid warnings. Signed-off-by: Simon Glass --- (no changes since v1) tools/patman/README | 3 ++- tools/patman/func_test.py | 23 ++++++++++++++++++- tools/patman/patchstream.py | 22 ++++++++++++++++++ .../0001-pci-Correct-cast-for-sandbox.patch | 2 +- ...-for-sandbox-in-fdtdec_setup_mem_siz.patch | 2 +- tools/patman/test/test01.txt | 4 ++-- 6 files changed, 50 insertions(+), 6 deletions(-) diff --git a/tools/patman/README b/tools/patman/README index 6664027ed7d..54036e1de4a 100644 --- a/tools/patman/README +++ b/tools/patman/README @@ -161,7 +161,8 @@ How to add tags =============== To make this script useful you must add tags like the following into any -commit. Most can only appear once in the whole series. +commit. Most can only appear once in the whole series. Tags should be placed +before the sign-off line / Change-Id. Series-to: email / alias Email address / alias to send patch series to (you can add this diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index b39e3f671dc..5732c674817 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -194,6 +194,9 @@ class TestFunctional(unittest.TestCase): 'fred': [self.fred], } + # NOTE: If you change this file you must also change the patch files in + # the same directory, since we assume that the metadata file matches the + # patched. If it doesn't, this test will fail. text = self._get_text('test01.txt') series = patchstream.get_metadata_for_test(text) cover_fname, args = self._create_patches_for_test(series) @@ -213,6 +216,10 @@ class TestFunctional(unittest.TestCase): os.remove(cc_file) lines = iter(out[0].getvalue().splitlines()) + self.assertIn('1 warnings for', next(lines)) + self.assertEqual( + "\t Tag 'Commit-notes' should be before sign-off / Change-Id", + next(lines)) self.assertEqual('Cleaned %s patches' % len(series.commits), next(lines)) self.assertEqual('Change log missing for v2', next(lines)) @@ -223,7 +230,7 @@ class TestFunctional(unittest.TestCase): self.assertEqual('', next(lines)) self.assertIn('Send a total of %d patches' % count, next(lines)) prev = next(lines) - for i, commit in enumerate(series.commits): + for i in range(len(series.commits)): self.assertEqual(' %s' % args[i], prev) while True: prev = next(lines) @@ -588,3 +595,17 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c self.assertEqual( ["Found possible blank line(s) at end of file 'lib/fdtdec.c'"], pstrm.commit.warn) + + def testTagsAfterSignoff(self): + """Test detection of tags after the signoff""" + text = '''This is a patch + +Signed-off-by: Terminator 2 +Series-changes: 2 +- A change + +''' + pstrm = PatchStream.process_text(text) + self.assertEqual( + ["Tag 'Series-changes' should be before sign-off / Change-Id"], + pstrm.commit.warn) diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 1cb4d6ed0dd..75b074a0185 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -81,6 +81,8 @@ class PatchStream: self.blank_count = 0 # Number of blank lines stored up self.state = STATE_MSG_HEADER # What state are we in? self.commit = None # Current commit + self.saw_signoff = False # Found sign-off line for this commit + self.saw_change_id = False # Found Change-Id for this commit @staticmethod def process_text(text, is_comment=False): @@ -176,6 +178,9 @@ class PatchStream: self.skip_blank = True self.section = [] + self.saw_signoff = False + self.saw_change_id = False + def _parse_version(self, value, line): """Parse a version from a *-changes tag @@ -343,6 +348,10 @@ class PatchStream: elif cover_match: name = cover_match.group(1) value = cover_match.group(2) + if self.saw_signoff or self.saw_change_id: + self._add_warn( + "Tag 'Cover-%s' should be before sign-off / Change-Id" % + name) if name == 'letter': self.in_section = 'cover' self.skip_blank = False @@ -374,6 +383,10 @@ class PatchStream: elif series_tag_match: name = series_tag_match.group(1) value = series_tag_match.group(2) + if self.saw_signoff or self.saw_change_id: + self._add_warn( + "Tag 'Series-%s' should be before sign-off / Change-Id" % + name) if name == 'changes': # value is the version number: e.g. 1, or 2 self.in_change = 'Series' @@ -385,6 +398,7 @@ class PatchStream: # Detect Change-Id tags elif change_id_match: value = change_id_match.group(1) + self.saw_change_id = True if self.is_log: if self.commit.change_id: raise ValueError( @@ -397,6 +411,10 @@ class PatchStream: elif commit_tag_match: name = commit_tag_match.group(1) value = commit_tag_match.group(2) + if self.saw_signoff or self.saw_change_id: + self._add_warn( + "Tag 'Commit-%s' should be before sign-off / Change-Id" % + name) if name == 'notes': self._add_to_commit(name) self.skip_blank = True @@ -427,6 +445,7 @@ class PatchStream: # Suppress duplicate signoffs elif signoff_match: + self.saw_signoff = True if (self.is_log or not self.commit or self.commit.CheckDuplicateSignoff(signoff_match.group(1))): out = [line] @@ -527,6 +546,8 @@ class PatchStream: re_fname = re.compile('diff --git a/(.*) b/.*') self._write_message_id(outfd) + self.saw_signoff = False + self.saw_change_id = False while True: line = infd.readline() @@ -637,6 +658,7 @@ def fix_patch(backup_dir, fname, series, cmt): infd = open(fname, 'r', encoding='utf-8') pst = PatchStream(series) pst.commit = cmt + cmt.warn = [] pst.process_stream(infd, outfd) infd.close() outfd.close() diff --git a/tools/patman/test/0001-pci-Correct-cast-for-sandbox.patch b/tools/patman/test/0001-pci-Correct-cast-for-sandbox.patch index 038943c2c9b..1efe0593fd3 100644 --- a/tools/patman/test/0001-pci-Correct-cast-for-sandbox.patch +++ b/tools/patman/test/0001-pci-Correct-cast-for-sandbox.patch @@ -14,7 +14,6 @@ cmd/pci.c:152:11: warning: format ‘%llx’ expects argument of type Fix it with a cast. -Signed-off-by: Simon Glass Commit-changes: 2 - Changes only for this commit @@ -24,6 +23,7 @@ about some things from the first commit END +Signed-off-by: Simon Glass Commit-notes: Some notes about the first commit diff --git a/tools/patman/test/0002-fdt-Correct-cast-for-sandbox-in-fdtdec_setup_mem_siz.patch b/tools/patman/test/0002-fdt-Correct-cast-for-sandbox-in-fdtdec_setup_mem_siz.patch index 56278a6ce9b..616ed4abd86 100644 --- a/tools/patman/test/0002-fdt-Correct-cast-for-sandbox-in-fdtdec_setup_mem_siz.patch +++ b/tools/patman/test/0002-fdt-Correct-cast-for-sandbox-in-fdtdec_setup_mem_siz.patch @@ -14,7 +14,6 @@ lib/fdtdec.c:1203:8: warning: format ‘%llx’ expects argument of type Fix it with a cast. -Signed-off-by: Simon Glass Series-to: u-boot Series-prefix: RFC Series-cc: Stefan Brüns @@ -40,6 +39,7 @@ This is a test of how the cover letter works END +Signed-off-by: Simon Glass --- fs/fat/fat.c | 1 + lib/efi_loader/efi_memory.c | 1 + diff --git a/tools/patman/test/test01.txt b/tools/patman/test/test01.txt index b238a8b4bab..6ef8faf66b8 100644 --- a/tools/patman/test/test01.txt +++ b/tools/patman/test/test01.txt @@ -12,7 +12,6 @@ Date: Sat Apr 15 15:39:08 2017 -0600 Fix it with a cast. - Signed-off-by: Simon Glass Commit-changes: 2 - second revision change @@ -22,6 +21,7 @@ Date: Sat Apr 15 15:39:08 2017 -0600 from the first commit END + Signed-off-by: Simon Glass Commit-notes: Some notes about the first commit @@ -41,7 +41,6 @@ Date: Sat Apr 15 15:39:08 2017 -0600 Fix it with a cast. - Signed-off-by: Simon Glass Series-to: u-boot Series-prefix: RFC Series-cc: Stefan Brüns @@ -67,3 +66,4 @@ Date: Sat Apr 15 15:39:08 2017 -0600 letter works END + Signed-off-by: Simon Glass