# HG changeset patch # User Mads Kiilerich # Date 2019-03-22 02:21:57 # Node ID c0b8d016cc3e07e93ec4097462a92d30a92128f0 # Parent e795ad3c7d5156ce722455726cfbe40740deb917 summary: fix odd code for allowing URI clone template to either be specified with {repo} or _{repoid} (Issue #336) Clarify that if the configured URI uses {repo}, then clone_uri_by_id must replace that with _{repoid}. Also, if the URI uses _{repoid}, it is _def_clone_uri that must be computed by replacing it with {node}. diff --git a/kallithea/controllers/summary.py b/kallithea/controllers/summary.py --- a/kallithea/controllers/summary.py +++ b/kallithea/controllers/summary.py @@ -119,10 +119,12 @@ class SummaryController(BaseRepoControll username = safe_str(request.authuser.username) _def_clone_uri = _def_clone_uri_by_id = c.clone_uri_tmpl - if '{repo}' in _def_clone_uri: - _def_clone_uri_by_id = _def_clone_uri.replace('{repo}', '_{repoid}') - elif '{repoid}' in _def_clone_uri: - _def_clone_uri_by_id = _def_clone_uri.replace('_{repoid}', '{repo}') + if '{repo}' in _def_clone_uri_by_id: + _def_clone_uri_by_id = _def_clone_uri_by_id.replace('{repo}', '_{repoid}') + elif '_{repoid}' in _def_clone_uri: + _def_clone_uri = _def_clone_uri.replace('_{repoid}', '{repo}') + else: + log.error("Configured clone_uri_tmpl %r has no '{repo}' or '_{repoid}' and cannot toggle to use repo id URLs", c.clone_uri_tmpl) c.clone_repo_url = c.db_repo.clone_url(user=username, uri_tmpl=_def_clone_uri)