mirror of
https://github.com/daylinmorgan/git-server.git
synced 2024-12-22 03:40:44 -06:00
parameterize soft-serve update script
This commit is contained in:
parent
c3276ca5e4
commit
f1b714bc89
2 changed files with 30 additions and 12 deletions
10
soft-serve.config.json
Normal file
10
soft-serve.config.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"paths": {
|
||||||
|
"src": "./gitea/git/repositories/daylin",
|
||||||
|
"dest": "./soft/repos"
|
||||||
|
},
|
||||||
|
"repos": {
|
||||||
|
"src": ["dotfiles", "git-server"],
|
||||||
|
"dest": ["config"]
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,21 +1,29 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
GITEA_REPOS = Path(__file__).parent / "gitea/git/repositories/daylin"
|
|
||||||
SOFT_REPOS = Path(__file__).parent / "soft/repos"
|
|
||||||
|
|
||||||
allowed = ["dotfiles", "git-server"]
|
def get_config():
|
||||||
soft_serve_only = ["config"]
|
with (Path(__file__).parent / "soft-serve.config.json").open("r") as f:
|
||||||
|
return json.load(f)
|
||||||
|
|
||||||
|
|
||||||
|
def get_name(config, repo):
|
||||||
|
name = repo.name.replace(".git", "")
|
||||||
|
dest = Path(config["paths"]["dest"]) / name
|
||||||
|
return name, dest
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
for repo in GITEA_REPOS.iterdir():
|
config = get_config()
|
||||||
name = repo.name.replace(".git", "")
|
|
||||||
dest = SOFT_REPOS / name
|
for repo in Path(config["paths"]["src"]).iterdir():
|
||||||
if name not in [*allowed, *soft_serve_only]:
|
name, dest = get_name(config, repo)
|
||||||
|
|
||||||
|
if name not in config["repos"]["src"]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print(f"{repo} >> {dest}")
|
print(f"{repo} >> {dest}")
|
||||||
|
@ -24,10 +32,10 @@ def main():
|
||||||
shutil.rmtree(dest)
|
shutil.rmtree(dest)
|
||||||
shutil.copytree(repo, dest)
|
shutil.copytree(repo, dest)
|
||||||
|
|
||||||
for repo in SOFT_REPOS.iterdir():
|
for repo in Path(config["paths"]["dest"]).iterdir():
|
||||||
name = repo.name.replace(".git", "")
|
name, dest = get_name(config, repo)
|
||||||
dest = SOFT_REPOS / name
|
|
||||||
if name not in [*allowed, *soft_serve_only]:
|
if name not in [*config["repos"]["src"], *config["repos"]["dest"]]:
|
||||||
print(f"pruning {name}")
|
print(f"pruning {name}")
|
||||||
shutil.rmtree(repo)
|
shutil.rmtree(repo)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue