From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4CE091A1E8E for ; Thu, 13 Oct 2016 02:30:00 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP; 13 Oct 2016 02:30:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,339,1473145200"; d="scan'208";a="1069854376" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.144]) by fmsmga002.fm.intel.com with ESMTP; 13 Oct 2016 02:29:59 -0700 From: Yonghong Zhu To: edk2-devel@lists.01.org Cc: Liming Gao Date: Thu, 13 Oct 2016 17:29:46 +0800 Message-Id: <1476350987-11628-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 MIME-Version: 1.0 Subject: [Patch] BaseTools: PatchCheck to align with wiki and report error for EFI_D_* X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 09:30:00 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch updates PatchCheck.py: 1.Update max line length to 70 that describe in wiki 2.remove the two [] when do the char count calculation 3.report error for EFI_D_* macro if it is used, recommend to use DEBUG_* format. Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu --- BaseTools/Scripts/PatchCheck.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py index 455c130..d423220 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -1,9 +1,9 @@ ## @file # Check a patch for various format issues # -# Copyright (c) 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2016, 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 # accompanies this distribution. The full text of the license may be # found at http://opensource.org/licenses/bsd-license.php @@ -14,11 +14,11 @@ # from __future__ import print_function VersionNumber = '0.1' -__copyright__ = "Copyright (c) 2015, Intel Corporation All rights reserved." +__copyright__ = "Copyright (c) 2015 - 2016, Intel Corporation All rights reserved." import email import argparse import os import re @@ -195,11 +195,11 @@ class CommitMessageCheck: if count <= 0: self.error('Empty commit message!') return - if count >= 1 and len(lines[0]) > 76: + if count >= 1 and len(lines[0]) > 70: self.error('First line of commit message (subject line) ' + 'is too long.') if count >= 1 and len(lines[0].strip()) == 0: self.error('First line of commit message (subject line) ' + @@ -208,11 +208,11 @@ class CommitMessageCheck: if count >= 2 and lines[1].strip() != '': self.error('Second line of commit message should be ' + 'empty.') for i in range(2, count): - if (len(lines[i]) > 76 and + if (len(lines[i]) > 70 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)) last_sig_line = None @@ -354,10 +354,12 @@ class GitDiffCheck: line) if '\t' in line: self.added_line_error('Tab character used', line) if len(stripped) < len(line): self.added_line_error('Trailing whitespace found', line) + if 'EFI_D_' in line: + self.added_line_error('EFI_D_* used, Please use DEBUG_* format', line) split_diff_re = re.compile(r''' (?P ^ diff \s+ --git \s+ a/.+ \s+ b/.+ $ ) @@ -471,11 +473,20 @@ class CheckOnePatch: self.commit_msg = mo.group('commit_message') self.commit_subject = pmail['subject'].replace('\r\n', '') self.commit_subject = self.commit_subject.replace('\n', '') - pfx_start = self.commit_subject.find('[') + pfx_start_tmp = self.commit_subject.find('[') + pfx_end = self.commit_subject.find(']', pfx_start_tmp) + pfx_start = pfx_start_tmp + while (pfx_end > pfx_start_tmp): + pfx_start_tmp = self.commit_subject.find('[', pfx_end) + if pfx_start_tmp >= 0: + pfx_end = self.commit_subject.find(']',pfx_start_tmp) + else: + break + if pfx_start >= 0: pfx_end = self.commit_subject.find(']') if pfx_end > pfx_start: self.commit_prefix = self.commit_subject[pfx_start + 1 : pfx_end] self.commit_subject = self.commit_subject[pfx_end + 1 :].lstrip() -- 2.6.1.windows.1