Mercurial > kallithea
changeset 7765:d83f41634d06
clone_url: introduce {system_user} and {hostname} variables that will be used for SSH clone URL
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Tue, 16 Jul 2019 12:30:15 +0200 |
parents | dbf3c33a516c |
children | 1a25c408d8a4 |
files | kallithea/lib/utils2.py kallithea/templates/admin/settings/settings_visual.html |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/utils2.py Tue Jul 16 12:25:10 2019 +0200 +++ b/kallithea/lib/utils2.py Tue Jul 16 12:30:15 2019 +0200 @@ -36,6 +36,7 @@ import datetime import urllib import binascii +import pwd import webob import urlobject @@ -414,6 +415,10 @@ def get_clone_url(clone_uri_tmpl, prefix_url, repo_name, repo_id, username=None): parsed_url = urlobject.URLObject(prefix_url) prefix = safe_unicode(urllib.unquote(parsed_url.path.rstrip('/'))) + try: + system_user = pwd.getpwuid(os.getuid()).pw_name + except Exception: # TODO: support all systems - especially Windows + system_user = 'kallithea' # hardcoded default value ... args = { 'scheme': parsed_url.scheme, 'user': safe_unicode(urllib.quote(safe_str(username or ''))), @@ -421,6 +426,8 @@ 'prefix': prefix, # undocumented, empty or starting with / 'repo': repo_name, 'repoid': str(repo_id), + 'system_user': safe_unicode(system_user), + 'hostname': parsed_url.hostname, } url = re.sub('{([^{}]+)}', lambda m: args.get(m.group(1), m.group(0)), clone_uri_tmpl)
--- a/kallithea/templates/admin/settings/settings_visual.html Tue Jul 16 12:25:10 2019 +0200 +++ b/kallithea/templates/admin/settings/settings_visual.html Tue Jul 16 12:30:15 2019 +0200 @@ -46,7 +46,11 @@ {user} current user username, {netloc} network location/server host of running Kallithea server, {repo} full repository name, - {repoid} ID of repository, can be used to construct clone-by-id''')}</span> + {repoid} ID of repository, can be used to construct clone-by-id, + {system_user} name of the Kallithea system user, + {hostname} server hostname + ''')} + </span> </div> </div>