From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web11.8117.1608019720454612047 for ; Tue, 15 Dec 2020 00:08:41 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: fengyunhua@byosoft.com.cn) Received: from localhost.localdomain ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Tue, 15 Dec 2020 16:08:36 +0800 X-WM-Sender: fengyunhua@byosoft.com.cn From: "fengyunhua" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Yuwei Chen Subject: [PATCH v2] BaseTools/Scripts: Check for added newline at end of file Date: Tue, 15 Dec 2020 16:08:11 +0800 Message-Id: <20201215080811.2305-1-fengyunhua@byosoft.com.cn> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2685 Adding blank lines at end of file is bad enough practice that git complains about it when importing patches (with git am): .git/rebase-apply/patch:105: new blank line at EOF. + warning: 1 line adds whitespace errors. Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen Signed-off-by: Yunhua Feng --- BaseTools/Scripts/PatchCheck.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py index 68c984ed0e..61ce0a8a43 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -316,6 +316,9 @@ class GitDiffCheck: self.new_bin = [] while self.line_num < self.count and self.format_ok: line_num = self.line_num + if self.lines[line_num].strip() == '+': + if line_num + 1 < self.count and self.lines[line_num + 1].startswith('diff --git') or self.lines[line_num + 1].strip() == '--': + self.format_error('New blank line at EOF.') self.run() assert(self.line_num > line_num) self.report_message_result() -- 2.27.0.windows.1