diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -2091,3 +2091,20 @@ def notification_description(notificatio from rhodecode.model.notification import NotificationModel return NotificationModel().make_description( notification, translate=request.translate) + + +def go_import_header(request, db_repo=None): + """ + Creates a header for go-import functionality in Go Lang + """ + + if not db_repo: + return + if 'go-get' not in request.GET: + return + + clone_url = db_repo.clone_url() + prefix = re.split(r'^https?:\/\/', clone_url)[-1] + # we have a repo and go-get flag, + return literal(''.format( + prefix, db_repo.repo_type, clone_url)) diff --git a/rhodecode/templates/base/root.mako b/rhodecode/templates/base/root.mako --- a/rhodecode/templates/base/root.mako +++ b/rhodecode/templates/base/root.mako @@ -3,7 +3,7 @@ <% c.template_context['repo_name'] = getattr(c, 'repo_name', '') - +go_import_header = '' if hasattr(c, 'rhodecode_db_repo'): c.template_context['repo_type'] = c.rhodecode_db_repo.repo_type c.template_context['repo_landing_commit'] = c.rhodecode_db_repo.landing_rev[1] @@ -29,6 +29,8 @@ c.template_context['default_user'] = {