From nobody Fri May 3 07:44:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1496908174818502.58733848211955; Thu, 8 Jun 2017 00:49:34 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 43E8B2094554C; Thu, 8 Jun 2017 00:48:22 -0700 (PDT) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AC4C920945523 for ; Thu, 8 Jun 2017 00:48:20 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2017 00:49:29 -0700 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by fmsmga005.fm.intel.com with ESMTP; 08 Jun 2017 00:49:28 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,313,1493708400"; d="scan'208";a="111854284" From: Hao Wu To: edk2-devel@lists.01.org Date: Thu, 8 Jun 2017 15:49:23 +0800 Message-Id: <20170608074924.12900-2-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20170608074924.12900-1-hao.a.wu@intel.com> References: <20170608074924.12900-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH 1/2] BaseTools/PatchCheck.py: Fix misreport for binary changes in patch X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Jordan Justen , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For a patch file that: 1. Contains a binary change 2. Contains any other changes after the binary change PatchCheck.py will complains with the following error: * Patch format error: diff found after end of patch Line: literal XXXX This commit resolves this misreport. Cc: Liming Gao Cc: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Liming Gao --- BaseTools/Scripts/PatchCheck.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck= .py index 7c3008233c..4bc697b1af 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 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials are licensed and made # available under the terms and conditions of the BSD License which @@ -265,7 +265,7 @@ class GitDiffCheck: if line.startswith('@@ '): self.state =3D PRE_PATCH elif len(line) >=3D 1 and line[0] not in ' -+' and \ - not line.startswith(r'\ No newline '): + not line.startswith(r'\ No newline ') and not self.binary: for line in self.lines[self.line_num + 1:]: if line.startswith('diff --git'): self.format_error('diff found after end of patch') @@ -300,7 +300,7 @@ class GitDiffCheck: elif self.state =3D=3D PATCH: if self.binary: pass - if line.startswith('-'): + elif line.startswith('-'): pass elif line.startswith('+'): self.check_added_line(line[1:]) --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 07:44:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1496908178111666.673227440195; Thu, 8 Jun 2017 00:49:38 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7C3022094554E; Thu, 8 Jun 2017 00:48:24 -0700 (PDT) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D0E1621967BE8 for ; Thu, 8 Jun 2017 00:48:21 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2017 00:49:30 -0700 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by fmsmga005.fm.intel.com with ESMTP; 08 Jun 2017 00:49:29 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,313,1493708400"; d="scan'208";a="111854290" From: Hao Wu To: edk2-devel@lists.01.org Date: Thu, 8 Jun 2017 15:49:24 +0800 Message-Id: <20170608074924.12900-3-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20170608074924.12900-1-hao.a.wu@intel.com> References: <20170608074924.12900-1-hao.a.wu@intel.com> Subject: [edk2] [PATCH 2/2] BaseTools/PatchCheck.py: Add warning info for new binary files X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Jordan Justen , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The commit adds the detection of adding new binary files in a patch file or in a commit. The following warning messages will be appended at the end of the script output: WARNING - The following binary files will be added into the repository: ... Cc: Liming Gao Cc: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Liming Gao --- BaseTools/Scripts/PatchCheck.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck= .py index 4bc697b1af..7bc5736dbf 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -243,6 +243,7 @@ class GitDiffCheck: self.count =3D len(self.lines) self.line_num =3D 0 self.state =3D START + self.new_bin =3D [] while self.line_num < self.count and self.format_ok: line_num =3D self.line_num self.run() @@ -254,6 +255,11 @@ class GitDiffCheck: return if self.ok: print('The code passed all checks.') + if self.new_bin: + print('\nWARNING - The following binary files will be added ' + + 'into the repository:') + for binary in self.new_bin: + print(' ' + binary) =20 def run(self): line =3D self.lines[self.line_num] @@ -276,21 +282,25 @@ class GitDiffCheck: if self.state =3D=3D START: if line.startswith('diff --git'): self.state =3D PRE_PATCH - self.set_filename(None) + self.filename =3D line[13:].split(' ',1)[0] + self.is_newfile =3D False + self.force_crlf =3D not self.filename.endswith('.sh') elif len(line.rstrip()) !=3D 0: self.format_error("didn't find diff command") self.line_num +=3D 1 elif self.state =3D=3D PRE_PATCH: - if line.startswith('+++ b/'): - self.set_filename(line[6:].rstrip()) if line.startswith('@@ '): self.state =3D PATCH self.binary =3D False - elif line.startswith('GIT binary patch'): + elif line.startswith('GIT binary patch') or \ + line.startswith('Binary files'): self.state =3D PATCH self.binary =3D True + if self.is_newfile: + self.new_bin.append(self.filename) else: ok =3D False + self.is_newfile =3D self.newfile_prefix_re.match(line) for pfx in self.pre_patch_prefixes: if line.startswith(pfx): ok =3D True @@ -320,22 +330,20 @@ class GitDiffCheck: 'new mode ', 'similarity index ', 'rename ', - 'Binary files ', ) =20 line_endings =3D ('\r\n', '\n\r', '\n', '\r') =20 - def set_filename(self, filename): - self.hunk_filename =3D filename - if filename: - self.force_crlf =3D not filename.endswith('.sh') - else: - self.force_crlf =3D True + newfile_prefix_re =3D \ + re.compile(r'''^ + index\ 0+\.\. + ''', + re.VERBOSE) =20 def added_line_error(self, msg, line): lines =3D [ msg ] - if self.hunk_filename is not None: - lines.append('File: ' + self.hunk_filename) + if self.filename is not None: + lines.append('File: ' + self.filename) lines.append('Line: ' + line) =20 self.error(*lines) --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel