# HG changeset patch # User Milka Kuzminski # Date 2021-01-22 07:56:20 # Node ID 35fb8d8f31b53f4321ef5720c46f59693c86a966 # Parent a708386857c8250525b807628ae18debe06ce7c2 clone-urls: allow custom clone by id template. diff --git a/rhodecode/apps/admin/views/settings.py b/rhodecode/apps/admin/views/settings.py --- a/rhodecode/apps/admin/views/settings.py +++ b/rhodecode/apps/admin/views/settings.py @@ -384,6 +384,7 @@ class AdminSettingsView(BaseAppView): ('markup_renderer', 'rhodecode_markup_renderer', 'unicode'), ('gravatar_url', 'rhodecode_gravatar_url', 'unicode'), ('clone_uri_tmpl', 'rhodecode_clone_uri_tmpl', 'unicode'), + ('clone_uri_id_tmpl', 'rhodecode_clone_uri_id_tmpl', 'unicode'), ('clone_uri_ssh_tmpl', 'rhodecode_clone_uri_ssh_tmpl', 'unicode'), ('support_url', 'rhodecode_support_url', 'unicode'), ('show_revision_number', 'rhodecode_show_revision_number', 'bool'), diff --git a/rhodecode/apps/repository/views/repo_summary.py b/rhodecode/apps/repository/views/repo_summary.py --- a/rhodecode/apps/repository/views/repo_summary.py +++ b/rhodecode/apps/repository/views/repo_summary.py @@ -83,14 +83,10 @@ class RepoSummaryView(RepoAppView): if self._rhodecode_user.username != User.DEFAULT_USER: username = safe_str(self._rhodecode_user.username) - _def_clone_uri = _def_clone_uri_id = c.clone_uri_tmpl + _def_clone_uri = c.clone_uri_tmpl + _def_clone_uri_id = c.clone_uri_id_tmpl _def_clone_uri_ssh = c.clone_uri_ssh_tmpl - if '{repo}' in _def_clone_uri: - _def_clone_uri_id = _def_clone_uri.replace('{repo}', '_{repoid}') - elif '{repoid}' in _def_clone_uri: - _def_clone_uri_id = _def_clone_uri.replace('_{repoid}', '{repo}') - c.clone_repo_url = self.db_repo.clone_url( user=username, uri_tmpl=_def_clone_uri) c.clone_repo_url_id = self.db_repo.clone_url( diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -342,6 +342,7 @@ def attach_context_attributes(context, r if request.GET.get('default_encoding'): context.default_encodings.insert(0, request.GET.get('default_encoding')) context.clone_uri_tmpl = rc_config.get('rhodecode_clone_uri_tmpl') + context.clone_uri_id_tmpl = rc_config.get('rhodecode_clone_uri_id_tmpl') context.clone_uri_ssh_tmpl = rc_config.get('rhodecode_clone_uri_ssh_tmpl') # INI stored diff --git a/rhodecode/lib/db_manage.py b/rhodecode/lib/db_manage.py --- a/rhodecode/lib/db_manage.py +++ b/rhodecode/lib/db_manage.py @@ -609,6 +609,7 @@ class DbManage(object): ('gravatar_url', User.DEFAULT_GRAVATAR_URL, 'unicode'), ('clone_uri_tmpl', Repository.DEFAULT_CLONE_URI, 'unicode'), + ('clone_uri_id_tmpl', Repository.DEFAULT_CLONE_URI_ID, 'unicode'), ('clone_uri_ssh_tmpl', Repository.DEFAULT_CLONE_URI_SSH, 'unicode'), ('support_url', '', 'unicode'), ('update_url', RhodeCodeSetting.DEFAULT_UPDATE_URL, 'unicode'), diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py --- a/rhodecode/model/forms.py +++ b/rhodecode/model/forms.py @@ -390,6 +390,7 @@ def ApplicationVisualisationForm(localiz rhodecode_markup_renderer = v.OneOf(['markdown', 'rst']) rhodecode_gravatar_url = v.UnicodeString(min=3) rhodecode_clone_uri_tmpl = v.UnicodeString(not_empty=False, if_empty=Repository.DEFAULT_CLONE_URI) + rhodecode_clone_uri_id_tmpl = v.UnicodeString(not_empty=False, if_empty=Repository.DEFAULT_CLONE_URI_ID) rhodecode_clone_uri_ssh_tmpl = v.UnicodeString(not_empty=False, if_empty=Repository.DEFAULT_CLONE_URI_SSH) rhodecode_support_url = v.UnicodeString() rhodecode_show_revision_number = v.StringBoolean(if_missing=False) diff --git a/rhodecode/templates/admin/settings/settings_visual.mako b/rhodecode/templates/admin/settings/settings_visual.mako --- a/rhodecode/templates/admin/settings/settings_visual.mako +++ b/rhodecode/templates/admin/settings/settings_visual.mako @@ -174,6 +174,9 @@ ${h.text('rhodecode_clone_uri_tmpl', size=60)} HTTP[S]
+ ${h.text('rhodecode_clone_uri_id_tmpl', size=60)} HTTP UID +
+
${h.text('rhodecode_clone_uri_ssh_tmpl', size=60)} SSH