core: added support for golang go import functionality

This commit is contained in:
Marcin Kuzminski 2017-10-29 10:14:24 +01:00
parent 10cad89493
commit 03068b3426
2 changed files with 20 additions and 1 deletions

View file

@ -2091,3 +2091,20 @@ def notification_description(notification, request):
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('<meta name="go-import" content="{} {} {}">'.format(
prefix, db_repo.repo_type, clone_url))

View file

@ -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'] = {
<title>${self.title()}</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
${h.go_import_header(request, getattr(c, 'rhodecode_db_repo', None))}
% if 'safari' in (request.user_agent or '').lower():
<meta name="referrer" content="origin">
% else: