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 4/6] BaseTools/PatchCheck: Extract the run_git() function
Date: Thu, 5 Dec 2019 17:12:32 +0100 [thread overview]
Message-ID: <20191205161234.25071-5-philmd@redhat.com> (raw)
In-Reply-To: <20191205161234.25071-1-philmd@redhat.com>
Extract run_git() from the CheckGitCommits class, so we can
reuse it from other places.
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 | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py
index f907e96b9501..fc1b077f3c64 100755
--- a/BaseTools/Scripts/PatchCheck.py
+++ b/BaseTools/Scripts/PatchCheck.py
@@ -18,6 +18,16 @@ import re
import subprocess
import sys
+def run_git(*args):
+ """Run git in a subprocess, return the command output."""
+ cmd = [ 'git' ]
+ cmd += args
+ p = subprocess.Popen(cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ Result = p.communicate()
+ return Result[0].decode('utf-8', 'ignore') if Result[0] and Result[0].find(b"fatal") !=0 else None
+
class Verbose:
SILENT, QUIET, ONELINE, NORMAL = range(4)
level = NORMAL
@@ -543,21 +553,12 @@ class CheckGitCommits:
if max_count is not None:
cmd.append('--max-count=' + str(max_count))
cmd.append(rev_spec)
- out = self.run_git(*cmd)
+ out = run_git(*cmd)
return out.split() if out else []
def read_patch_from_git(self, commit):
# Run git to get the commit patch
- return self.run_git('show', '--pretty=email', '--no-textconv', commit)
-
- def run_git(self, *args):
- cmd = [ 'git' ]
- cmd += args
- p = subprocess.Popen(cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
- Result = p.communicate()
- return Result[0].decode('utf-8', 'ignore') if Result[0] and Result[0].find(b"fatal")!=0 else None
+ return run_git('show', '--pretty=email', '--no-textconv', commit)
class CheckOnePatchFile:
"""Performs a patch check for a single file.
--
2.21.0
next prev parent reply other threads:[~2019-12-05 16:14 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 ` [PATCH 2/6] BaseTools/PatchCheck: Add a --quiet option Philippe Mathieu-Daudé
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 ` Philippe Mathieu-Daudé [this message]
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-5-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