From 8f2146470004a63806d6f0f21a0356269b71e402 Mon Sep 17 00:00:00 2001 From: Joey Vagedes Date: Thu, 26 Oct 2023 11:38:39 -0700 Subject: [PATCH] package_table: Get repo name from url Attempts to retrive the repository name from the url associated with either the origin or the first remote if the origin does not exist. If that fails, it will continue to resort to BASE. --- edk2toollib/database/tables/package_table.py | 4 ++++ tests.unit/database/test_package_table.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/edk2toollib/database/tables/package_table.py b/edk2toollib/database/tables/package_table.py index 9e24f1cb..4db3bfe6 100644 --- a/edk2toollib/database/tables/package_table.py +++ b/edk2toollib/database/tables/package_table.py @@ -50,6 +50,10 @@ def parse(self, db_cursor: Cursor, pathobj: Edk2Path, id: str, env: dict) -> Non for file in Path(pathobj.WorkspacePath).rglob("*.dec"): pkg = pathobj.GetContainingPackage(str(file)) containing_repo = "BASE" + if "origin" in repo.remotes: + containing_repo = repo.remotes.origin.url.split("/")[-1].split(".git")[0].upper() + elif len(repo.remotes) > 0: + containing_repo = repo.remotes[0].url.split("/")[-1].split(".git")[0].upper() if repo: for submodule in repo.submodules: if submodule.abspath in str(file): diff --git a/tests.unit/database/test_package_table.py b/tests.unit/database/test_package_table.py index a22a37cb..40e2c473 100644 --- a/tests.unit/database/test_package_table.py +++ b/tests.unit/database/test_package_table.py @@ -35,9 +35,9 @@ def test_basic_parse(tmp_path): results = db.connection.cursor().execute("SELECT * FROM package").fetchall() to_pass = { - ("QemuPkg", "BASE"): False, - ("QemuSbsaPkg", "BASE"): False, - ("QemuQ35Pkg", "BASE"): False, + ("QemuPkg", "MU_TIANO_PLATFORMS"): False, + ("QemuSbsaPkg", "MU_TIANO_PLATFORMS"): False, + ("QemuQ35Pkg", "MU_TIANO_PLATFORMS"): False, ("SetupDataPkg", "Features/CONFIG"): False, } for result in results: