diff --git a/progit/app.py b/progit/app.py index 906a93f..2d55967 100644 --- a/progit/app.py +++ b/progit/app.py @@ -56,14 +56,14 @@ def index(): ) -@APP.route('/') -def view_repo(repo): +@APP.route('//') +def view_repo(user, repo): """ Front page of a specific repo. """ - if repo not in os.listdir(APP.config['GIT_FOLDER']): + reponame = os.path.join(APP.config['GIT_FOLDER'], user, repo) + if repo not in os.path.exists(reponame): flask.abort(404) - repo_obj = pygit2.Repository( - os.path.join(APP.config['GIT_FOLDER'], repo)) + repo_obj = pygit2.Repository(gitfolder) cnt = 0 last_commits = [] @@ -83,14 +83,14 @@ def view_repo(repo): ) -@APP.route('//branch/') -def view_repo_branch(repo, branchname): +@APP.route('///branch/') +def view_repo_branch(user, repo, branchname): """ Displays the information about a specific branch. """ - if repo not in os.listdir(APP.config['GIT_FOLDER']): + reponame = os.path.join(APP.config['GIT_FOLDER'], user, repo) + if repo not in os.path.exists(reponame): flask.abort(404) - repo_obj = pygit2.Repository( - os.path.join(APP.config['GIT_FOLDER'], repo)) + repo_obj = pygit2.Repository(gitfolder) if not branchname in repo_obj.listall_branches(): flask.abort(404) @@ -115,15 +115,15 @@ def view_repo_branch(repo, branchname): ) -@APP.route('//log') -@APP.route('//log/') -def view_log(repo, branchname=None): +@APP.route('///log') +@APP.route('///log/') +def view_log(user, repo, branchname=None): """ Displays the logs of the specified repo. """ - if repo not in os.listdir(APP.config['GIT_FOLDER']): + reponame = os.path.join(APP.config['GIT_FOLDER'], user, repo) + if repo not in os.path.exists(reponame): flask.abort(404) - repo_obj = pygit2.Repository( - os.path.join(APP.config['GIT_FOLDER'], repo)) + repo_obj = pygit2.Repository(gitfolder) if branchname and not branchname in repo_obj.listall_branches(): flask.abort(404) @@ -164,16 +164,15 @@ def view_log(repo, branchname=None): ) -@APP.route('//blob//') -@APP.route('//blob//') -def view_file(repo, identifier, filename): +@APP.route('///blob//') +@APP.route('///blob//') +def view_file(user, repo, identifier, filename): """ Displays the content of a file or a tree for the specified repo. """ - - if repo not in os.listdir(APP.config['GIT_FOLDER']): - flask.abort(404, 'Git not found') - repo_obj = pygit2.Repository( - os.path.join(APP.config['GIT_FOLDER'], repo)) + reponame = os.path.join(APP.config['GIT_FOLDER'], user, repo) + if repo not in os.path.exists(reponame): + flask.abort(404) + repo_obj = pygit2.Repository(gitfolder) if identifier in repo_obj.listall_branches(): branchname = identifier @@ -230,14 +229,14 @@ def view_file(repo, identifier, filename): ) -@APP.route('//') -def view_commit(repo, commitid): +@APP.route('///') +def view_commit(user, repo, commitid): """ Render a commit in a repo """ - if repo not in os.listdir(APP.config['GIT_FOLDER']): + reponame = os.path.join(APP.config['GIT_FOLDER'], user, repo) + if repo not in os.path.exists(reponame): flask.abort(404) - repo_obj = pygit2.Repository( - os.path.join(APP.config['GIT_FOLDER'], repo)) + repo_obj = pygit2.Repository(gitfolder) try: commit = repo_obj.get(commitid) @@ -271,15 +270,15 @@ def view_commit(repo, commitid): ) -@APP.route('//tree/') -@APP.route('//tree/') -def view_tree(repo, identifier=None): +@APP.route('///tree/') +@APP.route('///tree/') +def view_tree(user, repo, identifier=None): """ Render the tree of the repo """ - if repo not in os.listdir(APP.config['GIT_FOLDER']): + reponame = os.path.join(APP.config['GIT_FOLDER'], user, repo) + if repo not in os.path.exists(reponame): flask.abort(404) - repo_obj = pygit2.Repository( - os.path.join(APP.config['GIT_FOLDER'], repo)) + repo_obj = pygit2.Repository(gitfolder) if identifier in repo_obj.listall_branches(): branchname = identifier