Changeset - c0b8d016cc3e
[Not reviewed]
default
0 1 0
Mads Kiilerich - 7 years ago 2019-03-22 02:21:57
mads@kiilerich.com
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}.
1 file changed with 6 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/summary.py
Show inline comments
 
@@ -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)
0 comments (0 inline, 0 general)