mirror of
https://git.alemi.dev/gitshell.git
synced 2024-11-21 15:04:51 +01:00
feat: fetch mirrors in subdirs too
This commit is contained in:
parent
2bb737e89b
commit
702267a7a1
1 changed files with 10 additions and 5 deletions
|
@ -1,10 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
GIT_ROOT = os.environ.get("GIT_ROOT_DIR") or "/srv/git/"
|
||||
GIT_ROOT = Path(os.environ.get("GIT_ROOT_DIR") or "/srv/git/")
|
||||
|
||||
def is_mirror(repo):
|
||||
cmd = ["git", "config", "-f", f"{GIT_ROOT}{repo}/config", "remote.origin.mirror"]
|
||||
|
@ -29,8 +29,8 @@ def push_all(repo):
|
|||
subprocess.run(["git", "push", "origin"], cwd=GIT_ROOT+repo)
|
||||
#subprocess.run([f"{GIT_ROOT}.hooks/post-update"], cwd=GIT_ROOT+repo)
|
||||
|
||||
if __name__ == "__main__":
|
||||
for element in os.listdir(GIT_ROOT):
|
||||
def run_on_all_repos(root: Path):
|
||||
for element in os.listdir(root):
|
||||
if element.endswith(".git"):
|
||||
if is_mirror(element):
|
||||
direction = get_direction(element)
|
||||
|
@ -38,4 +38,9 @@ if __name__ == "__main__":
|
|||
push_all(element)
|
||||
if direction == "down":
|
||||
fetch_all(element)
|
||||
|
||||
elif os.path.isdir(root / element):
|
||||
run_on_all_repos(root / element)
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_on_all_repos(GIT_ROOT)
|
||||
|
||||
|
|
Loading…
Reference in a new issue