From c98c3441f3763eda26df3185549613784530ca9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 6 Aug 2020 00:08:50 +0200 Subject: [PATCH] Share setup between git fresh init and clone This also fixes the terribly outdated setup in clone --- gitsrht/repos.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/gitsrht/repos.py b/gitsrht/repos.py index 2ab6e46..f0ad5fa 100644 --- a/gitsrht/repos.py +++ b/gitsrht/repos.py @@ -83,11 +83,15 @@ class GitRepoApi(SimpleRepoApi): repository_class=Repository) def do_init_repo(self, owner, repo): - # Note: update gitsrht-shell when changing this + # Note: update gitsrht-shell when changing this, + # do_clone_repo(), or _repo_config_init() subprocess.run(["mkdir", "-p", repo.path], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) subprocess.run(["git", "init", "--bare"], cwd=repo.path, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + self._repo_config_init(repo) + + def _repo_config_init(self, repo): subprocess.run(["git", "config", "srht.repo-id", str(repo.id)], check=True, cwd=repo.path, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) # We handle this ourselves in the post-update hook, and git's @@ -123,13 +127,4 @@ class GitRepoApi(SimpleRepoApi): subprocess.run(["mkdir", "-p", repo.path], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) subprocess.run(["git", "clone", "--bare", source, repo.path]) - subprocess.run(["git", "config", "srht.repo-id", str(repo.id)], check=True, - cwd=repo.path, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - subprocess.run(["ln", "-s", - post_update, - os.path.join(repo.path, "hooks", "update") - ], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - subprocess.run(["ln", "-s", - post_update, - os.path.join(repo.path, "hooks", "post-update") - ], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + self._repo_config_init(repo) -- 2.38.4