[edk2-devel] [PATCH] BaseTools/Scripts: Check for added newline at end of file

Bob Feng bob.c.feng at intel.com
Tue Dec 15 04:31:26 UTC 2020


Hi Yunhua,

I tested this patch.  And I found if there are multiple files change in one patch, your change can only detect the "new blank" error for the last file.

Thanks,
Bob

-----Original Message-----
From: Yunhua Feng <fengyunhua at byosoft.com.cn> 
Sent: Monday, December 14, 2020 8:32 AM
To: devel at edk2.groups.io
Cc: Feng, Bob C <bob.c.feng at intel.com>; Liming Gao <gaoliming at byosoft.com.cn>; Chen, Christine <yuwei.chen at intel.com>
Subject: [PATCH] BaseTools/Scripts: Check for added newline at end of file

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 <bob.c.feng at intel.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen at intel.com>
Signed-off-by: Yunhua Feng <fengyunhua at byosoft.com.cn>
---
 BaseTools/Scripts/PatchCheck.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py index 68c984ed0e..1859cdc580 100755
--- a/BaseTools/Scripts/PatchCheck.py
+++ b/BaseTools/Scripts/PatchCheck.py
@@ -316,6 +316,8 @@ class GitDiffCheck:
         self.new_bin = []
         while self.line_num < self.count and self.format_ok:
             line_num = self.line_num
+            if line_num == self.count - 1 and self.lines[line_num].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




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#68838): https://edk2.groups.io/g/devel/message/68838
Mute This Topic: https://groups.io/mt/78940455/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list