Extract run_git() from the CheckGitCommits class, so we can reuse it from other places.
Cc: Bob Feng <bob.c.f...@intel.com> Cc: Liming Gao <liming....@intel.com> Signed-off-by: Philippe Mathieu-Daude <phi...@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 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#51792): https://edk2.groups.io/g/devel/message/51792 Mute This Topic: https://groups.io/mt/67005111/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-