diff options
Diffstat (limited to 'lorrycontroller/lsupstreams.py')
-rw-r--r-- | lorrycontroller/lsupstreams.py | 42 |
1 files changed, 5 insertions, 37 deletions
diff --git a/lorrycontroller/lsupstreams.py b/lorrycontroller/lsupstreams.py index b31a385..a535174 100644 --- a/lorrycontroller/lsupstreams.py +++ b/lorrycontroller/lsupstreams.py @@ -54,7 +54,7 @@ class HostRepositoryLister(object): if self.app_settings['debug-fake-upstream-host']: repo_paths = self.get_fake_ls_output(host_info) else: - repo_paths = self.get_real_ls_output(statedb, host_info) + repo_paths = self.get_real_ls_output(host_info) return repo_paths @@ -68,25 +68,8 @@ class HostRepositoryLister(object): return obj['ls-output'] return None - def get_real_ls_output(self, statedb, host_info): - if host_info['type'] == 'gitlab': - return lorrycontroller.Gitlab(host_info['host'], - host_info['type_params'] - ['private-token']) \ - .list_projects() - - gitano = lorrycontroller.new_gitano_command( - statedb, host_info['host']) - output = gitano.ls() - return self.parse_ls_output(output) - - def parse_ls_output(self, ls_output): - repo_paths = [] - for line in ls_output.splitlines(): - words = line.split(None, 1) - if words[0].startswith('R') and len(words) == 2: - repo_paths.append(words[1]) - return repo_paths + def get_real_ls_output(self, host_info): + return lorrycontroller.get_upstream_host(host_info).list_repos() def skip_ignored_repos(self, host, repo_paths): ignored_patterns = json.loads(host['ignore']) @@ -156,23 +139,8 @@ class HostRepositoryLister(object): } def construct_lorry_url(self, host_info, remote_path): - if host_info['type'] == 'gitlab': - return lorrycontroller.Gitlab(host_info['host'], - host_info['type_params'] - ['private-token']) \ - .get_project_url(host_info['protocol'], - remote_path) - - vars = dict(host_info) - vars['remote_path'] = remote_path - - patterns = { - 'ssh': 'ssh://git@{host}/{remote_path}', - 'https':'https://{username}:{password}@{host}/git/{remote_path}', - 'http': 'http://{host}/git/{remote_path}', - } - - return patterns[host_info['protocol']].format(**vars) + return lorrycontroller.get_upstream_host(host_info) \ + .get_repo_url(remote_path) class ForceLsUpstream(lorrycontroller.LorryControllerRoute): |