diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 9862de2..2f3a6fb 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -553,20 +553,26 @@ def view_raw_file(repo, identifier, filename=None, username=None): return (data, 200, headers) -#@APP.route('///') -#@APP.route('//') -#@APP.route('/fork////') -#@APP.route('/fork///') -#def view_commit_old(repo, commitid, username=None): - #""" Render a commit in a repo - #""" - #print repo, commitid, username - #tmp = '%s/%s' % (repo, commitid) - #if not pagure.lib.get_project(SESSION, tmp, user=username): - #return flask.redirect(flask.url_for( - #'view_commit', repo=repo, commitid=commitid, username=username)) - #else: - #return view_repo(tmp, username=username) +@APP.route('///') +@APP.route('//') +@APP.route('/fork////') +@APP.route('/fork///') +def view_commit_old(repo, commitid, username=None): + """ Redirect from the old view_commit to the new one. + + This method aims to provide backward compatibility with the old URL + scheme where the commit id was right after the repo name. + This is problematic since we now allow up to one slash ('/') in the + project name, making the url parsing a little trickier. + So if the element after the '/' is exactly 40 characters long, then we + consider it's a commit hash and redirect to the new URL scheme for + viewing commits. + If the element is more (not possible) or less than 40 characters, then + the other URLs should catch it. + + """ + return flask.redirect(flask.url_for( + 'view_commit', repo=repo, commitid=commitid, username=username)) @APP.route('//c//')