From 135f7ec31ccc691b626d465a70fcac97baa895f7 Mon Sep 17 00:00:00 2001 From: jwansek Date: Mon, 19 Sep 2022 19:08:29 +0100 Subject: Added automatically restarting the web ui when a new repo is created --- make_repo.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'make_repo.py') diff --git a/make_repo.py b/make_repo.py index 6d8f3eb..0e2c9d1 100755 --- a/make_repo.py +++ b/make_repo.py @@ -27,7 +27,7 @@ if not os.path.exists(conf_path): CONFIG = configparser.ConfigParser() CONFIG.read(conf_path) -repo_name = urllib.parse.quote_plus(input("Input repository name: ")) +repo_name = input("Input repository name: ").replace(" ", "_") if not repo_name.endswith(".git"): repo_name += ".git" repo_dir = os.path.join(CONFIG.get("git", "repo_path"), repo_name) @@ -92,7 +92,7 @@ if input("Would you like the repository to remain bare? Useful for making mirror print("") selected_index = int(input("\nSelect .gitignore template: ")) - if selected_index != 0: + if selected_index != 1: shutil.copy(os.path.join(gitignore_templates_dir, templates[selected_index - 1]) + ".gitignore", ".gitignore", follow_symlinks = True) licenses_templates_dir = CONFIG.get("git", "license_templates") @@ -104,7 +104,7 @@ if input("Would you like the repository to remain bare? Useful for making mirror print("") selected_index = int(input("\nSelect license template: ")) - if selected_index != 0: + if selected_index != 1: with open(os.path.join(licenses_templates_dir, templates[selected_index - 1]) + ".txt", "r") as f: jinja_template = jinja2.Template(f.read()) @@ -119,6 +119,15 @@ if input("Would you like the repository to remain bare? Useful for making mirror subprocess.run(["git", "commit", "-m", "Initialized repository"]) subprocess.run(["git", "push", "origin", "master"]) +# could do this with the docker API instead maybe +proc = subprocess.Popen(CONFIG.get("git", "restart_ui_cmd").split(), stdout = subprocess.PIPE) +while True: + line = proc.stdout.readline() + if not line: + break + print(line.decode()) + + print(""" Repository created. You can now clone or add remote: git remote add other %s -- cgit v1.2.3