aboutsummaryrefslogtreecommitdiff
path: root/mirror.py
blob: 0ffff6cca74be4001770ed6135727caedc456468 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import toml
import pathlib
import os

__here__ = pathlib.Path(__file__).parent

with open(__here__ / "mirrors.toml", "r") as f:
    repositories = toml.load(f)

for path in repositories.keys():
    pathlib.mkdir(path, exist_ok=True)
    local_path = pathlib.Path(path)
    primary_url = repositories[path]["primary"]
    secondary_urls = repositories[path]["secondary"]
    if os.path.isfile(local_path / "git-daemon-export-ok"):
        subprocess.run(["git", "remote", "update", primary_url])
    else:
        # TODO: clone repository
        pass