From 4ea41a78f874dfa3446b77f9359543035e815bbf Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 01 2018 10:13:57 +0000 Subject: Fix showing the proper URLs in the repo overview Fixes https://pagure.io/pagure/issue/2924 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 2ac19c7..45b6bda 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -64,6 +64,20 @@ from pagure.decorators import ( _log = logging.getLogger(__name__) +def get_git_url_ssh(): + """ Return the GIT SSH URL to be displayed in the UI based on the + content of the configuration file. + """ + git_url_ssh = pagure_config.get('GIT_URL_SSH') + if authenticated() and git_url_ssh: + try: + git_url_ssh = git_url_ssh.format( + username=flask.g.fas_user.username) + except (KeyError, IndexError): + pass + return git_url_ssh + + @UI_NS.route('/.git') @UI_NS.route('//.git') @UI_NS.route('/fork//.git') @@ -129,14 +143,6 @@ def view_repo(repo, username=None, namespace=None): 'ui_ns.view_raw_file', username=username, repo=repo_db.name, identifier=branchname, filename='')) - git_url_ssh = pagure_config.get('GIT_URL_SSH') - if authenticated() and git_url_ssh: - try: - git_url_ssh = git_url_ssh.format( - username=flask.g.fas_user.username) - except (KeyError, IndexError): - pass - return flask.render_template( 'repo_info.html', select='overview', @@ -150,7 +156,7 @@ def view_repo(repo, username=None, namespace=None): last_commits=last_commits, tree=tree, form=pagure.forms.ConfirmationForm(), - git_url_ssh=git_url_ssh, + git_url_ssh=get_git_url_ssh(), ) @@ -246,6 +252,7 @@ def view_repo_branch(repo, branchname, username=None, namespace=None): readme=readme, diff_commits=diff_commits, form=pagure.forms.ConfirmationForm(), + git_url_ssh=get_git_url_ssh(), )