[edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update func to return absolute paths

Michael Kubacki posted 4 patches 3 years, 10 months ago
There is a newer version of this series
[edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update func to return absolute paths
Posted by Michael Kubacki 3 years, 10 months ago
From: Michael Kubacki <michael.kubacki@microsoft.com>

Currently, UncrustifyCheck._get_git_ignored_paths() is documented to
return a list of absolute file paths but it currently returns a list
of relative file paths.

This change updates the function to return a list of absolute file
paths. The result is later compared to the list of absolute file
paths for files to run against Uncrustify.

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

diff --git a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
index 82db7a5a438b..dc133fecc4b2 100644
--- a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
+++ b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
@@ -292,7 +292,11 @@ class UncrustifyCheck(ICiBuildPlugin):
                 f"An error occurred reading git ignore settings. This will prevent Uncrustify from running against the expected set of files.")
 
         # Note: This will potentially be a large list, but at least sorted
-        return outstream_buffer.getvalue().strip().splitlines()
+        rel_paths = outstream_buffer.getvalue().strip().splitlines()
+        abs_paths = []
+        for path in rel_paths:
+            abs_paths.append(os.path.join(self._abs_workspace_path, path))
+        return abs_paths
 
     def _get_git_submodule_paths(self) -> List[str]:
         """
-- 
2.28.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87810): https://edk2.groups.io/g/devel/message/87810
Mute This Topic: https://groups.io/mt/89944182/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update func to return absolute paths
Posted by Michael D Kinney 3 years, 10 months ago
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael Kubacki
> Sent: Monday, March 21, 2022 6:58 PM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Sean Brogan
> <sean.brogan@microsoft.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
> Subject: [edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update func to return absolute paths
> 
> From: Michael Kubacki <michael.kubacki@microsoft.com>
> 
> Currently, UncrustifyCheck._get_git_ignored_paths() is documented to
> return a list of absolute file paths but it currently returns a list
> of relative file paths.
> 
> This change updates the function to return a list of absolute file
> paths. The result is later compared to the list of absolute file
> paths for files to run against Uncrustify.
> 
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
> ---
>  .pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
> index 82db7a5a438b..dc133fecc4b2 100644
> --- a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
> +++ b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
> @@ -292,7 +292,11 @@ class UncrustifyCheck(ICiBuildPlugin):
>                  f"An error occurred reading git ignore settings. This will prevent Uncrustify from running against the expected
> set of files.")
> 
>          # Note: This will potentially be a large list, but at least sorted
> -        return outstream_buffer.getvalue().strip().splitlines()
> +        rel_paths = outstream_buffer.getvalue().strip().splitlines()
> +        abs_paths = []
> +        for path in rel_paths:
> +            abs_paths.append(os.path.join(self._abs_workspace_path, path))
> +        return abs_paths
> 
>      def _get_git_submodule_paths(self) -> List[str]:
>          """
> --
> 2.28.0.windows.1
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#87810): https://edk2.groups.io/g/devel/message/87810
> Mute This Topic: https://groups.io/mt/89944182/1643496
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [michael.d.kinney@intel.com]
> -=-=-=-=-=-=
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87838): https://edk2.groups.io/g/devel/message/87838
Mute This Topic: https://groups.io/mt/89944182/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update func to return absolute paths
Posted by Michael D Kinney 3 years, 10 months ago
Hi Michael,

I meant to ask.  Is there a reason you are not normalizing the 
file paths os.path.normpath() before performing the path comparison?

I am concerned that a mix of '/', '\' and '..' in YAML file may
not detect what is supposed to be a matching path.

Perhaps this is a topic that applies to IgnoreFiles feature for
all plugins and can be addressed in a separate patch.

Mike

> -----Original Message-----
> From: Kinney, Michael D <michael.d.kinney@intel.com>
> Sent: Tuesday, March 22, 2022 9:07 AM
> To: devel@edk2.groups.io; mikuback@linux.microsoft.com; Kinney, Michael D <michael.d.kinney@intel.com>
> Cc: Gao, Liming <gaoliming@byosoft.com.cn>; Sean Brogan <sean.brogan@microsoft.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
> Subject: RE: [edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update func to return absolute paths
> 
> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
> 
> Mike
> 
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael Kubacki
> > Sent: Monday, March 21, 2022 6:58 PM
> > To: devel@edk2.groups.io
> > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Sean Brogan
> > <sean.brogan@microsoft.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
> > Subject: [edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update func to return absolute paths
> >
> > From: Michael Kubacki <michael.kubacki@microsoft.com>
> >
> > Currently, UncrustifyCheck._get_git_ignored_paths() is documented to
> > return a list of absolute file paths but it currently returns a list
> > of relative file paths.
> >
> > This change updates the function to return a list of absolute file
> > paths. The result is later compared to the list of absolute file
> > paths for files to run against Uncrustify.
> >
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> > Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
> > ---
> >  .pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
> > index 82db7a5a438b..dc133fecc4b2 100644
> > --- a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
> > +++ b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
> > @@ -292,7 +292,11 @@ class UncrustifyCheck(ICiBuildPlugin):
> >                  f"An error occurred reading git ignore settings. This will prevent Uncrustify from running against the
> expected
> > set of files.")
> >
> >          # Note: This will potentially be a large list, but at least sorted
> > -        return outstream_buffer.getvalue().strip().splitlines()
> > +        rel_paths = outstream_buffer.getvalue().strip().splitlines()
> > +        abs_paths = []
> > +        for path in rel_paths:
> > +            abs_paths.append(os.path.join(self._abs_workspace_path, path))
> > +        return abs_paths
> >
> >      def _get_git_submodule_paths(self) -> List[str]:
> >          """
> > --
> > 2.28.0.windows.1
> >
> >
> >
> > -=-=-=-=-=-=
> > Groups.io Links: You receive all messages sent to this group.
> > View/Reply Online (#87810): https://edk2.groups.io/g/devel/message/87810
> > Mute This Topic: https://groups.io/mt/89944182/1643496
> > Group Owner: devel+owner@edk2.groups.io
> > Unsubscribe: https://edk2.groups.io/g/devel/unsub [michael.d.kinney@intel.com]
> > -=-=-=-=-=-=
> >



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87839): https://edk2.groups.io/g/devel/message/87839
Mute This Topic: https://groups.io/mt/89944182/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update func to return absolute paths
Posted by Michael Kubacki 3 years, 10 months ago
Hi Mike,

Sorry I missed this message earlier.I made the change as I understood it 
in v2.

https://edk2.groups.io/g/devel/message/88342

Thanks,
Michael

On 3/22/2022 12:12 PM, Michael D Kinney wrote:
> Hi Michael,
> 
> I meant to ask.  Is there a reason you are not normalizing the
> file paths os.path.normpath() before performing the path comparison?
> 
> I am concerned that a mix of '/', '\' and '..' in YAML file may
> not detect what is supposed to be a matching path.
> 
> Perhaps this is a topic that applies to IgnoreFiles feature for
> all plugins and can be addressed in a separate patch.
> 
> Mike
> 
>> -----Original Message-----
>> From: Kinney, Michael D <michael.d.kinney@intel.com>
>> Sent: Tuesday, March 22, 2022 9:07 AM
>> To: devel@edk2.groups.io; mikuback@linux.microsoft.com; Kinney, Michael D <michael.d.kinney@intel.com>
>> Cc: Gao, Liming <gaoliming@byosoft.com.cn>; Sean Brogan <sean.brogan@microsoft.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
>> Subject: RE: [edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update func to return absolute paths
>>
>> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
>>
>> Mike
>>
>>> -----Original Message-----
>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael Kubacki
>>> Sent: Monday, March 21, 2022 6:58 PM
>>> To: devel@edk2.groups.io
>>> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Sean Brogan
>>> <sean.brogan@microsoft.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
>>> Subject: [edk2-devel] [PATCH v1 1/4] .pytool/Plugin/UncrustifyCheck: Update func to return absolute paths
>>>
>>> From: Michael Kubacki <michael.kubacki@microsoft.com>
>>>
>>> Currently, UncrustifyCheck._get_git_ignored_paths() is documented to
>>> return a list of absolute file paths but it currently returns a list
>>> of relative file paths.
>>>
>>> This change updates the function to return a list of absolute file
>>> paths. The result is later compared to the list of absolute file
>>> paths for files to run against Uncrustify.
>>>
>>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>>> Cc: Liming Gao <gaoliming@byosoft.com.cn>
>>> Cc: Sean Brogan <sean.brogan@microsoft.com>
>>> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
>>> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
>>> ---
>>>   .pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py | 6 +++++-
>>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
>>> index 82db7a5a438b..dc133fecc4b2 100644
>>> --- a/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
>>> +++ b/.pytool/Plugin/UncrustifyCheck/UncrustifyCheck.py
>>> @@ -292,7 +292,11 @@ class UncrustifyCheck(ICiBuildPlugin):
>>>                   f"An error occurred reading git ignore settings. This will prevent Uncrustify from running against the
>> expected
>>> set of files.")
>>>
>>>           # Note: This will potentially be a large list, but at least sorted
>>> -        return outstream_buffer.getvalue().strip().splitlines()
>>> +        rel_paths = outstream_buffer.getvalue().strip().splitlines()
>>> +        abs_paths = []
>>> +        for path in rel_paths:
>>> +            abs_paths.append(os.path.join(self._abs_workspace_path, path))
>>> +        return abs_paths
>>>
>>>       def _get_git_submodule_paths(self) -> List[str]:
>>>           """
>>> --
>>> 2.28.0.windows.1
>>>
>>>
>>>
>>> -=-=-=-=-=-=
>>> Groups.io Links: You receive all messages sent to this group.
>>> View/Reply Online (#87810): https://edk2.groups.io/g/devel/message/87810
>>> Mute This Topic: https://groups.io/mt/89944182/1643496
>>> Group Owner: devel+owner@edk2.groups.io
>>> Unsubscribe: https://edk2.groups.io/g/devel/unsub [michael.d.kinney@intel.com]
>>> -=-=-=-=-=-=
>>>
> 
> 
> 
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88346): https://edk2.groups.io/g/devel/message/88346
Mute This Topic: https://groups.io/mt/89944182/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-