From 7de972255141e462e68ac7a04e25ce2b13bc911a Mon Sep 17 00:00:00 2001 From: Brant Knudson Date: Mon, 1 Feb 2016 14:39:14 -0600 Subject: Correct project source guessing for OpenStack The links to the project source in all the developer docs are incorrect. The link for keystone is like http://git.openstack.org/cgit/p/openstack/keystone when it should be http://git.openstack.org/cgit/openstack/keystone See the link to "Project Source" on the left on http://docs.openstack.org/developer/keystone/ for example. Also, developers sometimes use a ".git" URL when they clone so strip off the .git. Change-Id: I8e7620119a169e3322d602ea633303cf9f941605 --- oslosphinx/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/oslosphinx/__init__.py b/oslosphinx/__init__.py index 2dd655d..77f962f 100644 --- a/oslosphinx/__init__.py +++ b/oslosphinx/__init__.py @@ -13,6 +13,7 @@ # under the License. import os +import re import six from six.moves.urllib import parse import subprocess @@ -33,7 +34,9 @@ def _guess_cgit_link(): if six.PY3: git_remote = os.fsdecode(git_remote) parsed = parse.urlparse(git_remote) - return CGIT_BASE + parsed.path.lstrip('/') + parsed = '/'.join(parsed.path.rstrip('/').split('/')[-2:]) + parsed = re.sub(r'\.git$', '', parsed) + return CGIT_BASE + parsed def _html_page_context(app, pagename, templatename, context, doctree): -- cgit v1.2.1