diff --git a/src/github_repo_auditor/portfolio_catalog.py b/src/github_repo_auditor/portfolio_catalog.py index 6546f55..b34d7aa 100644 --- a/src/github_repo_auditor/portfolio_catalog.py +++ b/src/github_repo_auditor/portfolio_catalog.py @@ -522,7 +522,9 @@ def catalog_entry_for_repo( basename_matches = [ entry for key, entry in repos.items() - if "/" in key and key.rsplit("/", 1)[-1] == normalized_repo_name + if not normalized_project_path + and "/" in key + and key.rsplit("/", 1)[-1] == normalized_repo_name ] if normalized_repo_name and len(basename_matches) == 1: return { diff --git a/tests/test_portfolio_catalog_truth_hunt.py b/tests/test_portfolio_catalog_truth_hunt.py new file mode 100644 index 0000000..b099d0a --- /dev/null +++ b/tests/test_portfolio_catalog_truth_hunt.py @@ -0,0 +1,27 @@ +from __future__ import annotations + +from github_repo_auditor.portfolio_catalog import catalog_entry_for_repo + + +def test_catalog_does_not_apply_another_checkout_path_lifecycle_by_basename() -> None: + catalog = { + "repos": { + "retired/legacy-app": { + "lifecycle_state": "archived", + "catalog_key": "retired/legacy-app", + "has_explicit_entry": True, + } + } + } + + entry = catalog_entry_for_repo( + { + "name": "legacy-app", + "full_name": "current-owner/legacy-app", + "path": "apps/legacy-app", + }, + catalog, + ) + + assert entry["has_explicit_entry"] is False + assert entry["lifecycle_state"] == ""