aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaise Thompson <blaise@untzag.com>2021-06-17 21:28:09 -0500
committerBlaise Thompson <blaise@untzag.com>2021-06-17 21:28:09 -0500
commit243a1783e06c2a13ceb51ed55b2089c8a5be33ba (patch)
tree48a7f1098e9bd2adffe6e525a99a7a1d68a74b3c
parent530d2d27806c15743019056f89d0854a93762854 (diff)
minimum viable with bugs
-rw-r--r--mirror.py21
-rw-r--r--mirrors.toml2
2 files changed, 15 insertions, 8 deletions
diff --git a/mirror.py b/mirror.py
index 0ffff6c..14051e2 100644
--- a/mirror.py
+++ b/mirror.py
@@ -1,20 +1,27 @@
import toml
import pathlib
import os
+import subprocess
__here__ = pathlib.Path(__file__).parent
-with open(__here__ / "mirrors.toml", "r") as f:
+with open("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)
+ local_path.mkdir(exist_ok=True, parents=True)
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
+ os.chdir(str(local_path))
+ if not pathlib.Path("git-daemon-export-ok").is_file():
+ subprocess.run(["git", "init", "--bare"])
+ subprocess.run(["git", "remote", "add", "origin", primary_url])
+ pathlib.Path("git-daemon-export-ok").touch()
+ subprocess.run(["git", "remote", "update"])
+ subprocess.run(["git", "fetch", "origin", "'*:*'"])
+ for url in secondary_urls:
+ print(url)
+ subprocess.run(["git", "push", url, "--all"])
+
diff --git a/mirrors.toml b/mirrors.toml
index 71f8c5d..6645045 100644
--- a/mirrors.toml
+++ b/mirrors.toml
@@ -1,5 +1,5 @@
["uw-madison-chem-shops/wisconsin-photoreactor.git"]
primary = "https://github.com/uw-madison-chem-shops/wisconsin-photoreactor.git"
-secondary = ["git@git.chem.wisc.edu:gellman-group/wisconsin-photoreactor.git",
+secondary = ["https://git.chem.wisc.edu/gellman-group/wisconsin-photoreactor.git",
"git@gitlab.com:uw-madison-chem-shops/wisconsin-photoreactor.git"]