Skip to content

Commit

Permalink
package_table: Get repo name from url
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Javagedes committed Nov 1, 2023
1 parent 0cbc919 commit 8f21464
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions edk2toollib/database/tables/package_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions tests.unit/database/test_package_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8f21464

Please sign in to comment.