public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] BaseTools/Scripts: Check for added newline at end of file
@ 2020-12-14  0:32 fengyunhua
  2020-12-15  4:31 ` Bob Feng
  0 siblings, 1 reply; 3+ messages in thread
From: fengyunhua @ 2020-12-14  0:32 UTC (permalink / raw)
  To: devel; +Cc: Bob Feng, Liming Gao, Yuwei Chen

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 | 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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] BaseTools/Scripts: Check for added newline at end of file
  2020-12-14  0:32 [PATCH] BaseTools/Scripts: Check for added newline at end of file fengyunhua
@ 2020-12-15  4:31 ` Bob Feng
  2020-12-15  7:08   ` 回复: " fengyunhua
  0 siblings, 1 reply; 3+ messages in thread
From: Bob Feng @ 2020-12-15  4:31 UTC (permalink / raw)
  To: Yunhua Feng, devel@edk2.groups.io; +Cc: Liming Gao, Chen, Christine

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@byosoft.com.cn> 
Sent: Monday, December 14, 2020 8:32 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@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@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 | 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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* 回复: [PATCH] BaseTools/Scripts: Check for added newline at end of file
  2020-12-15  4:31 ` Bob Feng
@ 2020-12-15  7:08   ` fengyunhua
  0 siblings, 0 replies; 3+ messages in thread
From: fengyunhua @ 2020-12-15  7:08 UTC (permalink / raw)
  To: 'Feng, Bob C', devel
  Cc: 'Liming Gao', 'Chen, Christine'

Hi Bob,
  I will update this patch.
Thanks,
Yunhua

-----邮件原件-----
发件人: Feng, Bob C <bob.c.feng@intel.com> 
发送时间: 2020年12月15日 12:31
收件人: Yunhua Feng <fengyunhua@byosoft.com.cn>; devel@edk2.groups.io
抄送: Liming Gao <gaoliming@byosoft.com.cn>; Chen, Christine
<yuwei.chen@intel.com>
主题: RE: [PATCH] BaseTools/Scripts: Check for added newline at end of file

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@byosoft.com.cn> 
Sent: Monday, December 14, 2020 8:32 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao
<gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@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@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 | 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





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-15  7:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-14  0:32 [PATCH] BaseTools/Scripts: Check for added newline at end of file fengyunhua
2020-12-15  4:31 ` Bob Feng
2020-12-15  7:08   ` 回复: " fengyunhua

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox