From dac5ec886f7288696b0ab7d6532c839c0aa6eba3 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 15 Aug 2022 06:01:37 +0000 Subject: [PATCH] move soft serve update to sub-directory --- .gitignore | 3 ++- Makefile | 12 ++++++++---- docker-compose.yml | 2 +- .../config/soft-serve.config.json | 2 +- .../config/update-soft-serve-repos.py | 8 ++++++-- 5 files changed, 18 insertions(+), 9 deletions(-) rename soft-serve.config.json => soft/config/soft-serve.config.json (82%) rename update-soft-serve-repos.py => soft/config/update-soft-serve-repos.py (79%) diff --git a/.gitignore b/.gitignore index 5417622..b4b8061 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -soft/* gitea/* !gitea/gitea/ @@ -6,3 +5,5 @@ gitea/gitea/* !gitea/gitea/templates/ !gitea/gitea/public/ +soft/* +!soft/config/ diff --git a/Makefile b/Makefile index 27c8a06..d3dea85 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,13 @@ .PHONY: lint lint: - black *.py - prettier -w ./soft-serve.config.json + black soft/config/*.py + prettier -w ./soft/config/soft-serve.config.json .PHONY: update-soft-serve -update-soft-serve: - sudo ./update-soft-serve-repos.py +update-soft-serve: soft-repos docker compose restart soft-serve + +.PHONY: soft-repos +soft-repos: + ./soft/config/update-soft-serve-repos.py + diff --git a/docker-compose.yml b/docker-compose.yml index 89de4fe..55911fa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: restart: unless-stopped container_name: soft-serve volumes: - - ./soft:/soft-serve + - ./soft/data:/soft-serve ports: - 23231:23231 diff --git a/soft-serve.config.json b/soft/config/soft-serve.config.json similarity index 82% rename from soft-serve.config.json rename to soft/config/soft-serve.config.json index ba5ad3f..c1fe283 100644 --- a/soft-serve.config.json +++ b/soft/config/soft-serve.config.json @@ -1,7 +1,7 @@ { "paths": { "src": "./gitea/git/repositories/daylin", - "dest": "./soft/repos" + "dest": "./soft/data/repos" }, "repos": { "src": ["dotfiles", "git-server"], diff --git a/update-soft-serve-repos.py b/soft/config/update-soft-serve-repos.py similarity index 79% rename from update-soft-serve-repos.py rename to soft/config/update-soft-serve-repos.py index 63a4ca1..2624b4c 100755 --- a/update-soft-serve-repos.py +++ b/soft/config/update-soft-serve-repos.py @@ -16,11 +16,15 @@ def get_name(config, repo): return name, dest +def get_repo_path(config, repos): + return Path(__file__).parent.parent.parent / config["paths"][repos] + + def main(): config = get_config() - for repo in Path(config["paths"]["src"]).iterdir(): + for repo in get_repo_path(config, "src").iterdir(): name, dest = get_name(config, repo) if name not in config["repos"]["src"]: @@ -32,7 +36,7 @@ def main(): shutil.rmtree(dest) shutil.copytree(repo, dest) - for repo in Path(config["paths"]["dest"]).iterdir(): + for repo in get_repo_path(config, "dest").iterdir(): name, dest = get_name(config, repo) if name not in [*config["repos"]["src"], *config["repos"]["dest"]]: