feat: finalize gitea automation with default source and publish-ready dist
This commit is contained in:
@@ -244,20 +244,34 @@ def find_categories(client: GiteaClient, cfg: Config, cli_names: set[str]) -> li
|
||||
categories: list[str] = []
|
||||
|
||||
for entry in entries:
|
||||
if entry.get("type") != "dir":
|
||||
entry_type = entry.get("type")
|
||||
name = entry.get("name") or ""
|
||||
|
||||
# Support nested layout: rule/Surge/<Name>/<Name>.list
|
||||
if entry_type == "dir":
|
||||
if should_include_category(name, cfg, cli_names):
|
||||
categories.append(name)
|
||||
continue
|
||||
name = entry.get("name")
|
||||
if not name:
|
||||
continue
|
||||
if should_include_category(name, cfg, cli_names):
|
||||
categories.append(name)
|
||||
|
||||
# Support flat layout: rule/Surge/<Name>.list
|
||||
if entry_type == "file" and name.endswith(".list"):
|
||||
cat = name[: -len(".list")]
|
||||
if cat and should_include_category(cat, cfg, cli_names):
|
||||
categories.append(cat)
|
||||
|
||||
return sorted(categories)
|
||||
|
||||
|
||||
def build_one_category(client: GiteaClient, cfg: Config, name: str, base_out: Path) -> tuple[int, int]:
|
||||
source_rel_path = f"{cfg.source_root}/{name}/{cfg.source_filename_pattern.format(name=name)}"
|
||||
source_content = client.read_file(cfg.owner, cfg.repo, source_rel_path, cfg.ref)
|
||||
nested_path = f"{cfg.source_root}/{name}/{cfg.source_filename_pattern.format(name=name)}"
|
||||
flat_path = f"{cfg.source_root}/{cfg.source_filename_pattern.format(name=name)}"
|
||||
|
||||
source_rel_path = nested_path
|
||||
try:
|
||||
source_content = client.read_file(cfg.owner, cfg.repo, nested_path, cfg.ref)
|
||||
except Exception:
|
||||
source_rel_path = flat_path
|
||||
source_content = client.read_file(cfg.owner, cfg.repo, flat_path, cfg.ref)
|
||||
|
||||
rules = parse_rules(source_content)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user