From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lucky1.263xmail.com (lucky1.263xmail.com [211.157.147.132]) by mx.groups.io with SMTP id smtpd.web08.2704.1637735042079953722 for ; Tue, 23 Nov 2021 22:24:02 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: byosoft.net, ip: 211.157.147.132, mailfrom: byomail@byosoft.net) Received: from localhost (unknown [192.168.167.69]) by lucky1.263xmail.com (Postfix) with ESMTP id 60E94FD2A3 for ; Wed, 24 Nov 2021 14:23:58 +0800 (CST) X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-ADDR-CHECKED4: 1 X-SKE-CHECKED: 1 X-ABS-CHECKED: 1 X-ANTISPAM-LEVEL: 2 Received: from mail.byosoft.com.cn (unknown [58.240.74.242]) by smtp.263.net (postfix) whith ESMTP id P19189T139793382930176S1637735037689297_; Wed, 24 Nov 2021 14:23:58 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: byomail@byosoft.net X-SENDER: byomail@byosoft.net X-LOGIN-NAME: byomail@byosoft.net X-FST-TO: devel@edk2.groups.io X-RCPT-COUNT: 1 X-LOCAL-RCPT-COUNT: 0 X-SENDER-IP: 58.240.74.242 X-ATTACHMENT-NUM: 0 X-UNIQUE-TAG: <21f714131775d02ef91d21031408f448> X-System-Flag: 0 Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Wed, 24 Nov 2021 14:23:05 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 58.246.60.130 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: "'Michael D Kinney'" , Cc: "'Sean Brogan'" , "'Bret Barkelew'" , "'Michael Kubacki'" References: <20211123173131.1245-1-michael.d.kinney@intel.com> In-Reply-To: <20211123173131.1245-1-michael.d.kinney@intel.com> Subject: =?UTF-8?B?5Zue5aSNOiBbUGF0Y2ggVjIgMS8xXSAucHl0b29scy9QbHVnaW4vTGljZW5zZUNoZWNrOiBVc2UgdGVtcCBkaXJlY3RvcnkgZm9yIGdpdCBkaWZmIG91dHB1dA==?= Date: Wed, 24 Nov 2021 14:23:07 +0800 Message-ID: <006401d7e0fb$beed12e0$3cc738a0$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQH+UiT6r3ZkQzEP1VdV+qpOU5XZKqvFUy4g Sender: "gaoliming" Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Reviewed-by: Liming Gao > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: Michael D Kinney > =B7=A2=CB=CD=CA=B1=BC=E4: 2021=C4=EA11=D4=C224=C8=D5 1:32 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: Sean Brogan ; Bret Barkelew > ; Liming Gao ; > Michael Kubacki > =D6=F7=CC=E2: [Patch V2 1/1] .pytools/Plugin/LicenseCheck: Use temp = directory for git > diff output >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3746 >=20 > Use --output option in git diff command to remove code diffs > from build log on stdout when LicenseCheck plugin is run. > Instead, create a temp directory for the diff output file and > remove the temp directory after the diff output is processed. >=20 > Cc: Sean Brogan > Cc: Bret Barkelew > Cc: Liming Gao > Cc: Michael Kubacki > Signed-off-by: Michael D Kinney > --- > .pytool/Plugin/LicenseCheck/LicenseCheck.py | 20 ++++++++++++++------ > 1 file changed, 14 insertions(+), 6 deletions(-) >=20 > diff --git a/.pytool/Plugin/LicenseCheck/LicenseCheck.py > b/.pytool/Plugin/LicenseCheck/LicenseCheck.py > index 5733f7bf4ec0..7b998daf6f6b 100644 > --- a/.pytool/Plugin/LicenseCheck/LicenseCheck.py > +++ b/.pytool/Plugin/LicenseCheck/LicenseCheck.py > @@ -5,6 +5,7 @@ > ## >=20 > import os > +import shutil > import logging > import re > from io import StringIO > @@ -61,12 +62,19 @@ class LicenseCheck(ICiBuildPlugin): > # - Junit Logger > # - output_stream the StringIO output stream from this plugin = via > logging > def RunBuildPlugin(self, packagename, Edk2pathObj, pkgconfig, > environment, PLM, PLMHelper, tc, output_stream=3DNone): > - return_buffer =3D StringIO() > - params =3D "diff --unified=3D0 origin/master HEAD" > - RunCmd("git", params, outstream=3Dreturn_buffer) > - p =3D return_buffer.getvalue().strip() > - patch =3D p.split("\n") > - return_buffer.close() > + # Create temp directory > + temp_path =3D os.path.join(Edk2pathObj.WorkspacePath, = 'Build', > '.pytool', 'Plugin', 'LicenseCheck') > + if not os.path.exists(temp_path): > + os.makedirs(temp_path) > + # Output file to use for git diff operations > + temp_diff_output =3D os.path.join (temp_path, 'diff.txt') > + params =3D "diff --output=3D{} --unified=3D0 origin/master > HEAD".format(temp_diff_output) > + RunCmd("git", params) > + with open(temp_diff_output) as file: > + patch =3D file.read().strip().split("\n") > + # Delete temp directory > + if os.path.exists(temp_path): > + shutil.rmtree(temp_path) >=20 > ignore_files =3D [] > if "IgnoreFiles" in pkgconfig: > -- > 2.32.0.windows.1