aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cgit/repos
diff options
context:
space:
mode:
Diffstat (limited to 'cgit/repos')
-rw-r--r--cgit/repos/main.py5
-rw-r--r--cgit/repos/repo.py9
2 files changed, 12 insertions, 2 deletions
diff --git a/cgit/repos/main.py b/cgit/repos/main.py
index bc8fa72..e5e390f 100644
--- a/cgit/repos/main.py
+++ b/cgit/repos/main.py
@@ -78,6 +78,10 @@ class Config:
return self.impl.get('DEFAULT', 'owner', fallback=None)
@property
+ def via_ssh(self):
+ return self.impl.getboolean('DEFAULT', 'ssh', fallback=Repo.DEFAULT_VIA_SSH)
+
+ @property
def github_username(self):
return self.impl.get('GITHUB', 'username', fallback=None)
@@ -87,6 +91,7 @@ class Config:
def set_defaults(self):
Repo.DEFAULT_OWNER = self.default_owner
+ Repo.DEFAULT_VIA_SSH = self.via_ssh
GithubRepo.DEFAULT_USER = self.github_username
BitbucketRepo.DEFAULT_USER = self.bitbucket_username
diff --git a/cgit/repos/repo.py b/cgit/repos/repo.py
index a128dbf..7d0c4a5 100644
--- a/cgit/repos/repo.py
+++ b/cgit/repos/repo.py
@@ -8,6 +8,7 @@ import os.path
class Repo:
DEFAULT_OWNER = None
+ DEFAULT_VIA_SSH = True
@staticmethod
def extract_repo_name(repo_id):
@@ -36,13 +37,15 @@ class GithubRepo(Repo):
DEFAULT_USER = None
def __init__(self, repo_id, clone_url=None, owner=None, desc=None,
- homepage=None, user=DEFAULT_USER, via_ssh=True):
+ homepage=None, user=DEFAULT_USER, via_ssh=None):
if user is None:
if GithubRepo.DEFAULT_USER is None:
raise RuntimeError('neither explicit or default GitHub username was provided')
user = GithubRepo.DEFAULT_USER
name = Repo.extract_repo_name(repo_id)
if clone_url is None:
+ if via_ssh is None:
+ via_ssh = Repo.DEFAULT_VIA_SSH
if via_ssh:
clone_url = self.build_clone_url_ssh(user, name)
else:
@@ -69,13 +72,15 @@ class BitbucketRepo(Repo):
DEFAULT_USER = None
def __init__(self, repo_id, clone_url=None, owner=None, desc=None,
- homepage=None, user=DEFAULT_USER, via_ssh=True):
+ homepage=None, user=DEFAULT_USER, via_ssh=None):
if user is None:
if BitbucketRepo.DEFAULT_USER is None:
raise RuntimeError('neither explicit or default Bitbucket username was provided')
user = BitbucketRepo.DEFAULT_USER
name = Repo.extract_repo_name(repo_id)
if clone_url is None:
+ if via_ssh is None:
+ via_ssh = Repo.DEFAULT_VIA_SSH
if via_ssh:
clone_url = self.build_clone_url_ssh(user, name)
else: