public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch V2 1/1] .pytools/Plugin/LicenseCheck: Use temp directory for git diff output
@ 2021-11-23 17:31 Michael D Kinney
  2021-11-23 23:25 ` [edk2-devel] " Michael Kubacki
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michael D Kinney @ 2021-11-23 17:31 UTC (permalink / raw)
  To: devel; +Cc: Sean Brogan, Bret Barkelew, Liming Gao, Michael Kubacki

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3746

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.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 .pytool/Plugin/LicenseCheck/LicenseCheck.py | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

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 @@
 ##
 
 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=None):
-        return_buffer = StringIO()
-        params = "diff --unified=0 origin/master HEAD"
-        RunCmd("git", params, outstream=return_buffer)
-        p = return_buffer.getvalue().strip()
-        patch = p.split("\n")
-        return_buffer.close()
+        # Create temp directory
+        temp_path = 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 = os.path.join (temp_path, 'diff.txt')
+        params = "diff --output={} --unified=0 origin/master HEAD".format(temp_diff_output)
+        RunCmd("git", params)
+        with open(temp_diff_output) as file:
+            patch = file.read().strip().split("\n")
+        # Delete temp directory
+        if os.path.exists(temp_path):
+            shutil.rmtree(temp_path)
 
         ignore_files = []
         if "IgnoreFiles" in pkgconfig:
-- 
2.32.0.windows.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [Patch V2 1/1] .pytools/Plugin/LicenseCheck: Use temp directory for git diff output
  2021-11-23 17:31 [Patch V2 1/1] .pytools/Plugin/LicenseCheck: Use temp directory for git diff output Michael D Kinney
@ 2021-11-23 23:25 ` Michael Kubacki
  2021-11-24  6:23 ` 回复: " gaoliming
  2021-11-26 15:52 ` [edk2-devel] " Sean
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Kubacki @ 2021-11-23 23:25 UTC (permalink / raw)
  To: devel, michael.d.kinney
  Cc: Sean Brogan, Bret Barkelew, Liming Gao, Michael Kubacki

Acked-by: Michael Kubacki <michael.kubacki@microsoft.com>

On 11/23/2021 12:31 PM, Michael D Kinney wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3746
> 
> 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.
> 
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Michael Kubacki <michael.kubacki@microsoft.com>
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> ---
>   .pytool/Plugin/LicenseCheck/LicenseCheck.py | 20 ++++++++++++++------
>   1 file changed, 14 insertions(+), 6 deletions(-)
> 
> 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 @@
>   ##
>   
>   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=None):
> -        return_buffer = StringIO()
> -        params = "diff --unified=0 origin/master HEAD"
> -        RunCmd("git", params, outstream=return_buffer)
> -        p = return_buffer.getvalue().strip()
> -        patch = p.split("\n")
> -        return_buffer.close()
> +        # Create temp directory
> +        temp_path = 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 = os.path.join (temp_path, 'diff.txt')
> +        params = "diff --output={} --unified=0 origin/master HEAD".format(temp_diff_output)
> +        RunCmd("git", params)
> +        with open(temp_diff_output) as file:
> +            patch = file.read().strip().split("\n")
> +        # Delete temp directory
> +        if os.path.exists(temp_path):
> +            shutil.rmtree(temp_path)
>   
>           ignore_files = []
>           if "IgnoreFiles" in pkgconfig:
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* 回复: [Patch V2 1/1] .pytools/Plugin/LicenseCheck: Use temp directory for git diff output
  2021-11-23 17:31 [Patch V2 1/1] .pytools/Plugin/LicenseCheck: Use temp directory for git diff output Michael D Kinney
  2021-11-23 23:25 ` [edk2-devel] " Michael Kubacki
@ 2021-11-24  6:23 ` gaoliming
  2021-11-26 15:52 ` [edk2-devel] " Sean
  2 siblings, 0 replies; 4+ messages in thread
From: gaoliming @ 2021-11-24  6:23 UTC (permalink / raw)
  To: 'Michael D Kinney', devel
  Cc: 'Sean Brogan', 'Bret Barkelew',
	'Michael Kubacki'

Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>

> -----邮件原件-----
> 发件人: Michael D Kinney <michael.d.kinney@intel.com>
> 发送时间: 2021年11月24日 1:32
> 收件人: devel@edk2.groups.io
> 抄送: Sean Brogan <sean.brogan@microsoft.com>; Bret Barkelew
> <Bret.Barkelew@microsoft.com>; Liming Gao <gaoliming@byosoft.com.cn>;
> Michael Kubacki <michael.kubacki@microsoft.com>
> 主题: [Patch V2 1/1] .pytools/Plugin/LicenseCheck: Use temp directory for
git
> diff output
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3746
> 
> 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.
> 
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Michael Kubacki <michael.kubacki@microsoft.com>
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> ---
>  .pytool/Plugin/LicenseCheck/LicenseCheck.py | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> 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 @@
>  ##
> 
>  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=None):
> -        return_buffer = StringIO()
> -        params = "diff --unified=0 origin/master HEAD"
> -        RunCmd("git", params, outstream=return_buffer)
> -        p = return_buffer.getvalue().strip()
> -        patch = p.split("\n")
> -        return_buffer.close()
> +        # Create temp directory
> +        temp_path = 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 = os.path.join (temp_path, 'diff.txt')
> +        params = "diff --output={} --unified=0 origin/master
> HEAD".format(temp_diff_output)
> +        RunCmd("git", params)
> +        with open(temp_diff_output) as file:
> +            patch = file.read().strip().split("\n")
> +        # Delete temp directory
> +        if os.path.exists(temp_path):
> +            shutil.rmtree(temp_path)
> 
>          ignore_files = []
>          if "IgnoreFiles" in pkgconfig:
> --
> 2.32.0.windows.1






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [edk2-devel] [Patch V2 1/1] .pytools/Plugin/LicenseCheck: Use temp directory for git diff output
  2021-11-23 17:31 [Patch V2 1/1] .pytools/Plugin/LicenseCheck: Use temp directory for git diff output Michael D Kinney
  2021-11-23 23:25 ` [edk2-devel] " Michael Kubacki
  2021-11-24  6:23 ` 回复: " gaoliming
@ 2021-11-26 15:52 ` Sean
  2 siblings, 0 replies; 4+ messages in thread
From: Sean @ 2021-11-26 15:52 UTC (permalink / raw)
  To: devel, michael.d.kinney
  Cc: Sean Brogan, Bret Barkelew, Liming Gao, Michael Kubacki

Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>

On 11/23/2021 9:31 AM, Michael D Kinney wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3746
> 
> 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.
> 
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Michael Kubacki <michael.kubacki@microsoft.com>
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> ---
>   .pytool/Plugin/LicenseCheck/LicenseCheck.py | 20 ++++++++++++++------
>   1 file changed, 14 insertions(+), 6 deletions(-)
> 
> 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 @@
>   ##
>   
>   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=None):
> -        return_buffer = StringIO()
> -        params = "diff --unified=0 origin/master HEAD"
> -        RunCmd("git", params, outstream=return_buffer)
> -        p = return_buffer.getvalue().strip()
> -        patch = p.split("\n")
> -        return_buffer.close()
> +        # Create temp directory
> +        temp_path = 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 = os.path.join (temp_path, 'diff.txt')
> +        params = "diff --output={} --unified=0 origin/master HEAD".format(temp_diff_output)
> +        RunCmd("git", params)
> +        with open(temp_diff_output) as file:
> +            patch = file.read().strip().split("\n")
> +        # Delete temp directory
> +        if os.path.exists(temp_path):
> +            shutil.rmtree(temp_path)
>   
>           ignore_files = []
>           if "IgnoreFiles" in pkgconfig:
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-26 15:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-23 17:31 [Patch V2 1/1] .pytools/Plugin/LicenseCheck: Use temp directory for git diff output Michael D Kinney
2021-11-23 23:25 ` [edk2-devel] " Michael Kubacki
2021-11-24  6:23 ` 回复: " gaoliming
2021-11-26 15:52 ` [edk2-devel] " Sean

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox