Find an epic repo's checkout and project config by its name, and clone a missing one from the place of the epic's other repos
CI / tests (pull_request) Failing after 4m35s
CI / tests (pull_request) Failing after 4m35s
This commit is contained in:
@@ -350,6 +350,20 @@ def held(folder: pathlib.Path, home: pathlib.Path) -> ProjectConfig | Failure |
|
||||
return config if isinstance(config, Failure) else load(config[0], config[0], home)
|
||||
|
||||
|
||||
def named(name: str, home: pathlib.Path) -> ProjectConfig | Failure | None:
|
||||
"""The config of the project whose main checkout is a folder called name, which may not exist yet, loaded as `held` does; None where no config names one. A config that cannot be read fails every name, since it may be the one asked for."""
|
||||
files = []
|
||||
for file in configs(home):
|
||||
config = read(file, home)
|
||||
if isinstance(config, Failure):
|
||||
return config
|
||||
if config[0].name == name:
|
||||
files.append(file)
|
||||
if len(files) > 1:
|
||||
return Failure(f"{' and '.join(str(file) for file in files)} each name a checkout called {name}; only one config may")
|
||||
return held(files[0].parent, home) if files else None
|
||||
|
||||
|
||||
def configs(home: pathlib.Path) -> list[pathlib.Path]:
|
||||
"""Every project's config file under home, in key order. do-epic's machine-wide config is not a project's."""
|
||||
return sorted(file for file in (home / PROJECTS).glob(f"*/{CONFIG}") if file.parent.name != DO_EPIC)
|
||||
|
||||
Reference in New Issue
Block a user