~edwargix/git.sr.ht

c98c3441f3763eda26df3185549613784530ca9c — наб 4 years ago 10a8916
Share setup between git fresh init and clone

This also fixes the terribly outdated setup in clone
1 files changed, 6 insertions(+), 11 deletions(-)

M gitsrht/repos.py
M gitsrht/repos.py => gitsrht/repos.py +6 -11
@@ 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)