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
This commit is contained in:
Brant Knudson 2016-02-01 14:39:14 -06:00
parent 6903e98bfb
commit 7de9722551

View File

@ -13,6 +13,7 @@
# under the License. # under the License.
import os import os
import re
import six import six
from six.moves.urllib import parse from six.moves.urllib import parse
import subprocess import subprocess
@ -33,7 +34,9 @@ def _guess_cgit_link():
if six.PY3: if six.PY3:
git_remote = os.fsdecode(git_remote) git_remote = os.fsdecode(git_remote)
parsed = parse.urlparse(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): def _html_page_context(app, pagename, templatename, context, doctree):