From 5436998e2cb5ac3e2b886e297224646e08508b36 Mon Sep 17 00:00:00 2001 From: Brandon Parker Date: Tue, 31 May 2022 11:00:53 -0700 Subject: [PATCH] fix property lookups on config objects --- cumulusci/core/config/base_config.py | 9 ++++++--- cumulusci/core/config/tests/test_config.py | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cumulusci/core/config/base_config.py b/cumulusci/core/config/base_config.py index 44f0e819a5..915455b239 100644 --- a/cumulusci/core/config/base_config.py +++ b/cumulusci/core/config/base_config.py @@ -66,7 +66,7 @@ def __getattr__(self, name): ) assert not STRICT_GETATTR, message - return self.lookup(name) + return self.lookup(name, already_called_getattr=True) @classmethod @lru_cache @@ -82,7 +82,7 @@ def _all_allowed_names(cls): ret.update(d) return ret - def lookup(self, name, default=None): + def lookup(self, name, default=None, already_called_getattr=False): tree = name.split("__") if name.startswith("_"): raise AttributeError(f"Attribute {name} not found") @@ -102,4 +102,7 @@ def lookup(self, name, default=None): if value_found: return value else: - return self.defaults.get(name, default) + if not already_called_getattr and hasattr(self, name): + return getattr(self, name) + else: + return self.defaults.get(name, default) diff --git a/cumulusci/core/config/tests/test_config.py b/cumulusci/core/config/tests/test_config.py index ad4e53ea8c..fe736c937f 100644 --- a/cumulusci/core/config/tests/test_config.py +++ b/cumulusci/core/config/tests/test_config.py @@ -372,6 +372,11 @@ def test_repo_url_from_repo_info(self): config._repo_info = {"url": "https://github.com/SFDO-Tooling/CumulusCI"} assert config.repo_url == "https://github.com/SFDO-Tooling/CumulusCI" + def test_lookup_repo_branch(self): + config = BaseProjectConfig(UniversalConfig()) + config._repo_info = {"branch": "foo-bar-baz"} + assert config.lookup("repo_branch") == "foo-bar-baz" + def test_repo_url_no_repo_root(self): config = BaseProjectConfig(UniversalConfig()) with temporary_dir():