public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: devel@edk2.groups.io
Cc: Philippe Mathieu-Daude <philmd@redhat.com>,
	Bob Feng <bob.c.feng@intel.com>,
	Liming Gao <liming.gao@intel.com>
Subject: [PATCH 2/6] BaseTools/PatchCheck: Add a --quiet option
Date: Thu,  5 Dec 2019 17:12:30 +0100	[thread overview]
Message-ID: <20191205161234.25071-3-philmd@redhat.com> (raw)
In-Reply-To: <20191205161234.25071-1-philmd@redhat.com>

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


  parent reply	other threads:[~2019-12-05 16:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-05 16:12 [PATCH 0/6] BaseTools: Improve PatchCheck and add GitPostCommitHook Philippe Mathieu-Daudé
2019-12-05 16:12 ` [PATCH 1/6] BaseTools/PatchCheck: Stop parsing commit message after --- separator Philippe Mathieu-Daudé
2019-12-05 19:02   ` Laszlo Ersek
2019-12-05 16:12 ` Philippe Mathieu-Daudé [this message]
2019-12-05 16:12 ` [PATCH 3/6] BaseTools/Scripts: Add GitPostCommitHook.py Philippe Mathieu-Daudé
2019-12-05 19:24   ` Laszlo Ersek
2019-12-05 16:12 ` [PATCH 4/6] BaseTools/PatchCheck: Extract the run_git() function Philippe Mathieu-Daudé
2019-12-05 16:12 ` [PATCH 5/6] BaseTools/PatchCheck: Add printw() function to print warnings Philippe Mathieu-Daudé
2019-12-05 16:12 ` [PATCH 6/6] BaseTools/PatchCheck: Allow to print colored warnings Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191205161234.25071-3-philmd@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox