Add a --quiet option to only display warnings.
This will be useful when this script is called embedded.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com>
---
BaseTools/Scripts/PatchCheck.py | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py
index 8bcf857a7d15..f907e96b9501 100755
--- a/BaseTools/Scripts/PatchCheck.py
+++ b/BaseTools/Scripts/PatchCheck.py
@@ -19,7 +19,7 @@ import subprocess
import sys
class Verbose:
- SILENT, ONELINE, NORMAL = range(3)
+ SILENT, QUIET, ONELINE, NORMAL = range(4)
level = NORMAL
class CommitMessageCheck:
@@ -56,10 +56,10 @@ class CommitMessageCheck:
print(self.url)
def error(self, *err):
- if self.ok and Verbose.level > Verbose.ONELINE:
+ if self.ok and Verbose.level >= Verbose.QUIET:
print('The commit message format is not valid:')
self.ok = False
- if Verbose.level < Verbose.NORMAL:
+ if Verbose.level in [Verbose.SILENT, Verbose.ONELINE]:
return
count = 0
for line in err:
@@ -404,10 +404,10 @@ class GitDiffCheck:
self.error(err, err2)
def error(self, *err):
- if self.ok and Verbose.level > Verbose.ONELINE:
+ if self.ok and Verbose.level >= Verbose.QUIET:
print('Code format is not valid:')
self.ok = False
- if Verbose.level < Verbose.NORMAL:
+ if Verbose.level in [Verbose.SILENT, Verbose.ONELINE]:
return
count = 0
for line in err:
@@ -530,7 +530,8 @@ class CheckGitCommits:
print()
else:
blank_line = True
- print('Checking git commit:', commit)
+ if Verbose.level > Verbose.QUIET:
+ print('Checking git commit:', commit)
patch = self.read_patch_from_git(commit)
self.ok &= CheckOnePatch(commit, patch).ok
if not commits:
@@ -634,12 +635,17 @@ class PatchCheckApp:
group.add_argument("--oneline",
action="store_true",
help="Print one result per line")
+ group.add_argument("--quiet",
+ action="store_true",
+ help="Only print warnings and errors")
group.add_argument("--silent",
action="store_true",
help="Print nothing")
self.args = parser.parse_args()
if self.args.oneline:
Verbose.level = Verbose.ONELINE
+ if self.args.quiet:
+ Verbose.level = Verbose.QUIET
if self.args.silent:
Verbose.level = Verbose.SILENT
--
2.21.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#51788): https://edk2.groups.io/g/devel/message/51788
Mute This Topic: https://groups.io/mt/67003983/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-