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

fengyunhua posted 1 patch 3 years, 4 months ago
Failed in applying to current master (apply log)
BaseTools/Scripts/PatchCheck.py | 3 +++
1 file changed, 3 insertions(+)
[edk2-devel] [PATCH v2] BaseTools/Scripts: Check for added newline at end of file
Posted by fengyunhua 3 years, 4 months ago
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@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Yunhua Feng <fengyunhua@byosoft.com.cn>
---
 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




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#68850): https://edk2.groups.io/g/devel/message/68850
Mute This Topic: https://groups.io/mt/78972034/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-