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
 
@@ -110,28 +110,30 @@ class SummaryController(BaseRepoControll
 
        collection = c.db_repo_scm_instance
 
        c.cs_pagination = RepoPage(collection, page=p, items_per_page=size)
 
        page_revisions = [x.raw_id for x in list(c.cs_pagination)]
 
        c.cs_comments = c.db_repo.get_comments(page_revisions)
 
        c.cs_statuses = c.db_repo.statuses(page_revisions)
 

	
 
        if request.authuser.is_default_user:
 
            username = ''
 
        else:
 
            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)
 
        c.clone_repo_url_id = c.db_repo.clone_url(user=username,
 
                                                uri_tmpl=_def_clone_uri_by_id)
 

	
 
        if c.db_repo.enable_statistics:
 
            c.show_stats = True
 
        else:
 
            c.show_stats = False
 

	
 
        stats = Statistics.query() \
0 comments (0 inline, 0 general)