From e930f9e4f75983948a7b6cfcf0d844b935369e2a Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Wed, 31 Dec 2014 04:50:09 -0500 Subject: route: prepare to fix routing of hierarchical branch names Branch names in Git may be hierarchical (for example, "wip/parser/fix"), however, git-arr does not take this into account in its Bottle routing rules. Unfortunately, when updated to recognize hierarchical branch names, the rules become ambiguous in their present order since Bottle matches them in the order registered. The ambiguity results in incorrect matches. For instance, branch pages (/r//b//) are matched before tree pages (/r//b//t/), however, when branch names can be hierarchical, a tree path such as "/r/proj/b/branch/t/" also looks like a branch named "branch/t", and thus undesirably matches the branch rule rather than the tree rule. This problem can be resolved by adjusting the order of rules. Therefore, re-order the rules from most to least specific as a preparatory step prior to actually fixing them to accept hierarchical branch names. This is a purely textual relocation. No functional changes intended. Signed-off-by: Eric Sunshine Signed-off-by: Alberto Bertogli --- git-arr | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'git-arr') diff --git a/git-arr b/git-arr index 95455ec..66b49ba 100755 --- a/git-arr +++ b/git-arr @@ -214,13 +214,6 @@ def index(): def summary(repo): return dict(repo = repo) -@bottle.route('/r//b//') -@bottle.route('/r//b//.html') -@bottle.view('branch') -@with_utils -def branch(repo, bname, offset = 0): - return dict(repo = repo.new_in_branch(bname), offset = offset) - @bottle.route('/r//c//') @bottle.view('commit') @with_utils @@ -231,19 +224,6 @@ def commit(repo, cid): return dict(repo = repo, c=c) -@bottle.route('/r//b//t/') -@bottle.route('/r//b//t//') -@bottle.view('tree') -@with_utils -def tree(repo, bname, dirname = ''): - if dirname and not dirname.endswith('/'): - dirname = dirname + '/' - - dirname = git.smstr.from_url(dirname) - - r = repo.new_in_branch(bname) - return dict(repo = r, tree = r.tree(), dirname = dirname) - @bottle.route('/r//b//t/f=.html') @bottle.route('/r//b//t//f=.html') @bottle.view('blob') @@ -264,6 +244,26 @@ def blob(repo, bname, fname, dirname = ''): return dict(repo = r, dirname = dirname, fname = fname, blob = content) +@bottle.route('/r//b//t/') +@bottle.route('/r//b//t//') +@bottle.view('tree') +@with_utils +def tree(repo, bname, dirname = ''): + if dirname and not dirname.endswith('/'): + dirname = dirname + '/' + + dirname = git.smstr.from_url(dirname) + + r = repo.new_in_branch(bname) + return dict(repo = r, tree = r.tree(), dirname = dirname) + +@bottle.route('/r//b//') +@bottle.route('/r//b//.html') +@bottle.view('branch') +@with_utils +def branch(repo, bname, offset = 0): + return dict(repo = repo.new_in_branch(bname), offset = offset) + @bottle.route('/static/') def static(path): return bottle.static_file(path, root = static_path) -- cgit v1.2.3