From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web09.11712.1575562445942601429 for ; Thu, 05 Dec 2019 08:14:06 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z3OcSXB1; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575562444; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8dNDE5zzRmPtM0+4OMsRzTR0P5XSI2DsCE0oV/Yv6Rs=; b=Z3OcSXB1VDYob/RQb/bF2KfcUEQSACUfkv6fOwi/KYM/BldKpgObefOqLMxAsohXx71VNc 669nYiA3/BvS4V6i54QEImXITFU12MIzxoeWcBVJsrbYSZ932yUs/DRWtq+tXBrL45Nhpc ptMrDLtCNT2OeVEa/DvItF7wd46xK4Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-44-fjIOJZ-iNGufPHHZOzMtnA-1; Thu, 05 Dec 2019 11:12:51 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CB58E107B278; Thu, 5 Dec 2019 16:12:50 +0000 (UTC) Received: from x1w.redhat.com (ovpn-205-76.brq.redhat.com [10.40.205.76]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C39410013D9; Thu, 5 Dec 2019 16:12:49 +0000 (UTC) From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= To: devel@edk2.groups.io Cc: Philippe Mathieu-Daude , Bob Feng , Liming Gao Subject: [PATCH 4/6] BaseTools/PatchCheck: Extract the run_git() function Date: Thu, 5 Dec 2019 17:12:32 +0100 Message-Id: <20191205161234.25071-5-philmd@redhat.com> In-Reply-To: <20191205161234.25071-1-philmd@redhat.com> References: <20191205161234.25071-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: fjIOJZ-iNGufPHHZOzMtnA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Extract run_git() from the CheckGitCommits class, so we can reuse it from other places. Cc: Bob Feng Cc: Liming Gao Signed-off-by: Philippe Mathieu-Daude --- 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 =20 +def run_git(*args): + """Run git in a subprocess, return the command output.""" + cmd =3D [ 'git' ] + cmd +=3D args + p =3D subprocess.Popen(cmd, + stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.STDOUT) + Result =3D p.communicate() + return Result[0].decode('utf-8', 'ignore') if Result[0] and Result[0].= find(b"fatal") !=3D0 else None + class Verbose: SILENT, QUIET, ONELINE, NORMAL =3D range(4) level =3D NORMAL @@ -543,21 +553,12 @@ class CheckGitCommits: if max_count is not None: cmd.append('--max-count=3D' + str(max_count)) cmd.append(rev_spec) - out =3D self.run_git(*cmd) + out =3D run_git(*cmd) return out.split() if out else [] =20 def read_patch_from_git(self, commit): # Run git to get the commit patch - return self.run_git('show', '--pretty=3Demail', '--no-textconv', c= ommit) - - def run_git(self, *args): - cmd =3D [ 'git' ] - cmd +=3D args - p =3D subprocess.Popen(cmd, - stdout=3Dsubprocess.PIPE, - stderr=3Dsubprocess.STDOUT) - Result =3D p.communicate() - return Result[0].decode('utf-8', 'ignore') if Result[0] and Result= [0].find(b"fatal")!=3D0 else None + return run_git('show', '--pretty=3Demail', '--no-textconv', commit= ) =20 class CheckOnePatchFile: """Performs a patch check for a single file. --=20 2.21.0