From 530d2d27806c15743019056f89d0854a93762854 Mon Sep 17 00:00:00 2001 From: Blaise Thompson Date: Thu, 17 Jun 2021 20:41:39 -0500 Subject: initial commit --- mirror.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 mirror.py (limited to 'mirror.py') diff --git a/mirror.py b/mirror.py new file mode 100644 index 0000000..0ffff6c --- /dev/null +++ b/mirror.py @@ -0,0 +1,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 + -- cgit v1.2.3