cloner.detector_enabled
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
parent
ff1e90982a
commit
52c3d03e2f
|
@ -15,6 +15,7 @@ class Cloner:
|
|||
_dirs: RepoDirStructure = None
|
||||
_config: ClonerConfig = None
|
||||
_interval_file: str = "last-check-time"
|
||||
__detector_cfg = "detector.cfg"
|
||||
__submodule_cache: str = None
|
||||
_repo: RepoTool = None
|
||||
_repo_url: str = ""
|
||||
|
@ -202,3 +203,7 @@ class Cloner:
|
|||
scan_depth_limit = None
|
||||
# another levels are handled internally as non-recursive clones and discovers by repo-tool
|
||||
return self._repo.clone_recursive(url, self.__submodule_cache, scan_depth = scan_depth_limit)
|
||||
|
||||
@property
|
||||
def detector_enabled(self) -> bool:
|
||||
return os.path.exists(os.path.join(self._dirs.conf_dir, self.__detector_cfg))
|
||||
|
|
|
@ -61,7 +61,7 @@ class MockDirStruct:
|
|||
def __init__(self, tmp: Path):
|
||||
self.config = MockConfig()
|
||||
self.cache_dir = tmp.joinpath("cache")
|
||||
self.config_dir = tmp.joinpath("config")
|
||||
self.conf_dir = tmp.joinpath("config")
|
||||
self.repos_dir = tmp.joinpath("repos")
|
||||
self.raise_cache_exists = False
|
||||
|
||||
|
@ -457,3 +457,12 @@ def test_clone_recursive(tmp_path, path_repo_base, caplog):
|
|||
assert cloner.clone()
|
||||
patch_clone_recursive.assert_called_with(
|
||||
'https://repo', tmp_path.joinpath('cache', 'submodules').as_posix(), scan_depth = None)
|
||||
|
||||
def test_detector_enabled(cloner_dir_with_config):
|
||||
ds = MockDirStruct(cloner_dir_with_config)
|
||||
ds.config.cloner_repo_url = "http://mock"
|
||||
cl = Cloner(ds)
|
||||
assert not cl.detector_enabled
|
||||
Path(cloner_dir_with_config).joinpath("config", "detector.cfg").touch()
|
||||
assert cl.detector_enabled
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user