.pytool/EccCheck: Trim leading path to modified directory

The code changes in the patch is for trimming the leading path
to the modified directory in the .pytool/EccCheck script.
This is necessary when running Ecc on other repositories,
such as edk2-platforms, where the platform package is located
in a subfolder, like Platform/AMD/AmdPlatformPkg.

The EccCheck script checks for modified directories and expects them to start with the package name.
        #
        # Skip directory names that do not start with the package being scanned.
        #
        if file_dir.split('/')[0] != pkg:
                continue

However, if the package name is in a subfolder,
the "git diff" command gives a relative path,
like Platform/AMD, which causes the condition to be false.
"M       Platform/AMD/AmdPlatformPkg/Universal/LogoDxe/Logo.c"
As a result, EccCheck does not happen on modified files.

To fix this issue, the leading path needs to be trimmed
so that it starts from the directory name.
This change will not affect the existing check for the edk2 repository,
where all package names are at the first level directory.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Joey Vagedes <joey.vagedes@gmail.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
This commit is contained in:
Abdul Lateef Attar 2024-08-31 09:19:30 +00:00 committed by mergify[bot]
parent 1328938560
commit 9a4088777f
1 changed files with 5 additions and 0 deletions

View File

@ -182,6 +182,11 @@ class EccCheck(ICiBuildPlugin):
#
file_dir = os.path.dirname(file_path[-1])
#
# strip the prefix path till the package name
#
if pkg in file_dir:
file_dir = file_dir[file_dir.find(pkg):]
#
# Skip directory names that do not start with the package being scanned.
#
if file_dir.split('/')[0] != pkg: