diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2019-08-12 10:20:53 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2019-08-12 10:20:53 +0300 |
commit | d37fb2ae726446b79cb142e4b86a8ef7942043f4 (patch) | |
tree | 247e7213ccbaae8186e4aba46125131c72edba66 /pull/cgit.py | |
parent | remove pull.sh (diff) | |
download | cgitize-d37fb2ae726446b79cb142e4b86a8ef7942043f4.tar.gz cgitize-d37fb2ae726446b79cb142e4b86a8ef7942043f4.zip |
move options to a config file
Diffstat (limited to 'pull/cgit.py')
-rw-r--r-- | pull/cgit.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/pull/cgit.py b/pull/cgit.py index ec7876c..a6b4312 100644 --- a/pull/cgit.py +++ b/pull/cgit.py @@ -21,14 +21,13 @@ def _check_output(*args, **kwargs): class CGit: - def __init__(self, user, host, port): - self.user = user - self.host = host - self.ip = socket.gethostbyname(self.host) - self.port = port + def __init__(self, clone_url): + self.clone_url = clone_url def get_clone_url(self, repo): - return f'http://{self.user}@{self.ip}:{self.port}/git/{repo.repo_id}' + if self.clone_url is None: + return None + return self.clone_url.format(repo_id=repo.repo_id) class CGitRC: @@ -52,7 +51,11 @@ class CGitRC: clone_urls = [] if repo.clone_url is not None: clone_urls.append(repo.clone_url) - clone_urls.append(self.cgit.get_clone_url(repo)) + cgit_clone_url = self.cgit.get_clone_url(repo) + if cgit_clone_url is not None: + clone_urls.append(cgit_clone_url) + if not clone_urls: + return None clone_urls = ' '.join(clone_urls) return clone_urls |