From 59298d0208d4058016fffa1420f32da04fe35ff9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 06 2015 14:56:45 +0000 Subject: Move the get_repo_path utility method into the progit module --- diff --git a/progit/__init__.py b/progit/__init__.py index 7003349..881489e 100644 --- a/progit/__init__.py +++ b/progit/__init__.py @@ -310,6 +310,21 @@ def __get_file_in_tree(repo_obj, tree, filepath): repo_obj, repo_obj[el.oid], filepath[1:]) +def get_repo_path(repo): + """ Return the pat of the git repository corresponding to the provided + Repository object from the DB. + """ + if repo.is_fork: + repopath = os.path.join(APP.config['FORK_FOLDER'], repo.path) + else: + repopath = os.path.join(APP.config['GIT_FOLDER'], repo.path) + + if not os.path.exists(repopath): + flask.abort(404, 'No git repo found') + + return repopath + + # Import the application import progit.ui.app import progit.ui.admin diff --git a/progit/ui/fork.py b/progit/ui/fork.py index f656725..8ed182b 100644 --- a/progit/ui/fork.py +++ b/progit/ui/fork.py @@ -30,16 +30,6 @@ from progit import (APP, SESSION, LOG, __get_file_in_tree, cla_required, is_repo_admin, generate_gitolite_acls) -def _get_repo_path(repo): - """ Return the pat of the git repository corresponding to the provided - Repository object from the DB. - """ - if repo.is_fork: - repopath = os.path.join(APP.config['FORK_FOLDER'], repo.path) - else: - repopath = os.path.join(APP.config['GIT_FOLDER'], repo.path) - return repopath - def _get_parent_repo_path(repo): """ Return the path of the parent git repository corresponding to the