From 9a4088777fbe7941664ad9bb2bd78446d223cbf9 Mon Sep 17 00:00:00 2001 From: Abdul Lateef Attar Date: Sat, 31 Aug 2024 09:19:30 +0000 Subject: [PATCH] .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 Cc: Joey Vagedes Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Abdul Lateef Attar --- .pytool/Plugin/EccCheck/EccCheck.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pytool/Plugin/EccCheck/EccCheck.py b/.pytool/Plugin/EccCheck/EccCheck.py index 7235fcb55c..0002143f1a 100644 --- a/.pytool/Plugin/EccCheck/EccCheck.py +++ b/.pytool/Plugin/EccCheck/EccCheck.py @@ -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: