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/<repo>/b/<bname>/) are matched before tree pages (/r/<repo>/b/<bname>/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 <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
This commit is contained in:
parent
93b161c23e
commit
e930f9e4f7
40
git-arr
40
git-arr
@ -214,13 +214,6 @@ def index():
|
|||||||
def summary(repo):
|
def summary(repo):
|
||||||
return dict(repo = repo)
|
return dict(repo = repo)
|
||||||
|
|
||||||
@bottle.route('/r/<repo:repo>/b/<bname>/')
|
|
||||||
@bottle.route('/r/<repo:repo>/b/<bname>/<offset:int>.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/<repo:repo>/c/<cid:re:[0-9a-f]{5,40}>/')
|
@bottle.route('/r/<repo:repo>/c/<cid:re:[0-9a-f]{5,40}>/')
|
||||||
@bottle.view('commit')
|
@bottle.view('commit')
|
||||||
@with_utils
|
@with_utils
|
||||||
@ -231,19 +224,6 @@ def commit(repo, cid):
|
|||||||
|
|
||||||
return dict(repo = repo, c=c)
|
return dict(repo = repo, c=c)
|
||||||
|
|
||||||
@bottle.route('/r/<repo:repo>/b/<bname>/t/')
|
|
||||||
@bottle.route('/r/<repo:repo>/b/<bname>/t/<dirname:path>/')
|
|
||||||
@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/<repo:repo>/b/<bname>/t/f=<fname:path>.html')
|
@bottle.route('/r/<repo:repo>/b/<bname>/t/f=<fname:path>.html')
|
||||||
@bottle.route('/r/<repo:repo>/b/<bname>/t/<dirname:path>/f=<fname:path>.html')
|
@bottle.route('/r/<repo:repo>/b/<bname>/t/<dirname:path>/f=<fname:path>.html')
|
||||||
@bottle.view('blob')
|
@bottle.view('blob')
|
||||||
@ -264,6 +244,26 @@ def blob(repo, bname, fname, dirname = ''):
|
|||||||
|
|
||||||
return dict(repo = r, dirname = dirname, fname = fname, blob = content)
|
return dict(repo = r, dirname = dirname, fname = fname, blob = content)
|
||||||
|
|
||||||
|
@bottle.route('/r/<repo:repo>/b/<bname>/t/')
|
||||||
|
@bottle.route('/r/<repo:repo>/b/<bname>/t/<dirname:path>/')
|
||||||
|
@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/<repo:repo>/b/<bname>/')
|
||||||
|
@bottle.route('/r/<repo:repo>/b/<bname>/<offset:int>.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/<path:path>')
|
@bottle.route('/static/<path:path>')
|
||||||
def static(path):
|
def static(path):
|
||||||
return bottle.static_file(path, root = static_path)
|
return bottle.static_file(path, root = static_path)
|
||||||
|
Loading…
Reference in New Issue
Block a user