From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.32564.1578881599900543259 for ; Sun, 12 Jan 2020 18:13:20 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: bob.c.feng@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jan 2020 18:13:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,427,1571727600"; d="scan'208";a="241953439" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga002.jf.intel.com with ESMTP; 12 Jan 2020 18:13:19 -0800 Received: from shsmsx602.ccr.corp.intel.com (10.109.6.142) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 12 Jan 2020 18:13:18 -0800 Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by SHSMSX602.ccr.corp.intel.com (10.109.6.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 13 Jan 2020 10:13:17 +0800 Received: from shsmsx601.ccr.corp.intel.com ([10.109.6.141]) by SHSMSX601.ccr.corp.intel.com ([10.109.6.141]) with mapi id 15.01.1713.004; Mon, 13 Jan 2020 10:13:17 +0800 From: "Bob Feng" To: "Kinney, Michael D" , "devel@edk2.groups.io" CC: "Gao, Liming" , Laszlo Ersek , "Justen, Jordan L" Subject: Re: [Patch] BaseTools/Scripts/PatchCheck: Address false error conditions Thread-Topic: [Patch] BaseTools/Scripts/PatchCheck: Address false error conditions Thread-Index: AQHVyAjan5wnpXf2YUCXl18TtjW8e6fn3V9g Date: Mon, 13 Jan 2020 02:13:16 +0000 Message-ID: References: <20200110225358.8204-1-michael.d.kinney@intel.com> In-Reply-To: <20200110225358.8204-1-michael.d.kinney@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.36] MIME-Version: 1.0 Return-Path: bob.c.feng@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Mike, This patch can't apply to edk2 repo, please update. For this patch, Reviewed-by: Bob Feng Thanks, Bob -----Original Message----- From: Kinney, Michael D=20 Sent: Saturday, January 11, 2020 6:54 AM To: devel@edk2.groups.io Cc: Feng, Bob C ; Gao, Liming ;= Laszlo Ersek ; Justen, Jordan L Subject: [Patch] BaseTools/Scripts/PatchCheck: Address false error conditio= ns https://bugzilla.tianocore.org/show_bug.cgi?id=3D2406 * Always print subject line after the git commit id to make it easier to know the context of warnings or errors. * Allow UTF-8 characters in subject line * Error if subject line length > 75 without CVE-xxx-xxxxx present * Error if subject line length > 92 with CVE-xxxx-xxxxx present * If body line length is > 75, then print warning instead of error. Cc: Bob Feng Cc: Liming Gao Cc: Laszlo Ersek Cc: Jordan Justen Signed-off-by: Michael D Kinney --- BaseTools/Scripts/PatchCheck.py | 57 +++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck= .py index 9668025798..ff4572bb7c 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -1,7 +1,7 @@ ## @file # Check a patch for various format issues # -# Copyright (c) 2015 - 201= 9, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2020, Intel Corporation. All rights=20 +reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -35,6 +35,8 @@ class= CommitMessageCheck: self.subject =3D subject self.msg =3D message =20 + print (subject) + self.check_contributed_under() self.check_signed_off_by() self.check_misc_signatures() @@ -179,6 +181,8 @@ class CommitMessageCheck: for sig in self.sig_types: self.find_signatures(sig) =20 + cve_re =3D re.compile('CVE-[0-9]{4}-[0-9]{5}[^0-9]') + def check_overall_format(self): lines =3D self.msg.splitlines() =20 @@ -196,9 +200,26 @@ class CommitMessageCheck: self.error('Empty commit message!') return =20 - if count >=3D 1 and len(lines[0].rstrip()) >=3D 72: - self.error('First line of commit message (subject line) ' + - 'is too long.') + if count >=3D 1 and re.search(self.cve_re, lines[0]): + # + # If CVE-xxxx-xxxxx is present in subject line, then limit len= gth of + # subject line to 92 characters + # + if len(lines[0].rstrip()) >=3D 93: + self.error( + 'First line of commit message (subject line) is too lo= ng (%d >=3D 93).' % + (len(lines[0].rstrip())) + ) + else: + # + # If CVE-xxxx-xxxxx is not present in subject line, then limit + # length of subject line to 75 characters + # + if len(lines[0].rstrip()) >=3D 76: + self.error( + 'First line of commit message (subject line) is too lo= ng (%d >=3D 76).' % + (len(lines[0].rstrip())) + ) =20 if count >=3D 1 and len(lines[0].strip()) =3D=3D 0: self.error('First line of commit message (subject line) ' + @@= -212,7 +233,14 @@ class CommitMessageCheck: if (len(lines[i]) >=3D 76 and len(lines[i].split()) > 1 and not lines[i].startswith('git-svn-id:')): - self.error('Line %d of commit message is too long.' % (i += 1)) + # + # Print a warning if body line is longer than 75 character= s + # + print( + 'WARNING - Line %d of commit message is too long (%d >= =3D 76).' % + (i + 1, len(lines[i])) + ) + print(lines[i]) =20 last_sig_line =3D None for i in range(count - 1, 0, -1): @@ -503,8 +531,25 @@ class CheckOnePatch: else: self.stat =3D mo.group('stat') self.commit_msg =3D mo.group('commit_message') + # + # Parse subject line from email header. The subject line may be + # composed of multiple parts with different encodings. Decode and + # combine all the parts to produce a single string with the conten= ts of + # the decoded subject line. + # + parts =3D email.header.decode_header(pmail.get('subject')) + subject =3D '' + for (part, encoding) in parts: + if encoding: + part =3D part.decode(encoding) + else: + try: + part =3D part.decode() + except: + pass + subject =3D subject + part =20 - self.commit_subject =3D pmail['subject'].replace('\r\n', '') + self.commit_subject =3D subject.replace('\r\n', '') self.commit_subject =3D self.commit_subject.replace('\n', '') self.commit_subject =3D self.subject_prefix_re.sub('', self.commit= _subject, 1) =20 -- 2.21.0.windows.1