tree: pass branch name to view explicitly

Passing the branch name into the view indirectly via
Repo.new_in_branch() increases cognitive burden, thus outweighing
whatever minor convenience (if any) is gained by doing so. The code is
easier to reason about when the branch name is passed to the view
directly.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
This commit is contained in:
Eric Sunshine 2015-01-14 02:46:32 -05:00 committed by Alberto Bertogli
parent 46640c68b9
commit e6099cf272
2 changed files with 6 additions and 6 deletions

@ -256,8 +256,8 @@ def tree(repo, bname, dirname = ''):
dirname = git.smstr.from_url(dirname) dirname = git.smstr.from_url(dirname)
r = repo.new_in_branch(bname) return dict(repo = repo, branch = bname, tree = repo.tree(bname),
return dict(repo = r, tree = r.tree(), dirname = dirname) dirname = dirname)
@bottle.route('/r/<repo:repo>/b/<bname:path>/') @bottle.route('/r/<repo:repo>/b/<bname:path>/')
@bottle.route('/r/<repo:repo>/b/<bname:path>/<offset:int>.html') @bottle.route('/r/<repo:repo>/b/<bname:path>/<offset:int>.html')

@ -8,10 +8,10 @@
% else: % else:
% reltree = '../' * (len(dirname.split('/')) - 1) % reltree = '../' * (len(dirname.split('/')) - 1)
% end % end
% relroot = reltree + '../' * (len(repo.branch.split('/')) - 1) % relroot = reltree + '../' * (len(branch.split('/')) - 1)
<title>git &raquo; {{repo.name}} &raquo; <title>git &raquo; {{repo.name}} &raquo;
{{repo.branch}} &raquo; {{dirname.unicode}}</title> {{branch}} &raquo; {{dirname.unicode}}</title>
<link rel="stylesheet" type="text/css" <link rel="stylesheet" type="text/css"
href="{{relroot}}../../../../../static/git-arr.css"/> href="{{relroot}}../../../../../static/git-arr.css"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/> <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
@ -20,12 +20,12 @@
<body class="tree"> <body class="tree">
<h1><a href="{{relroot}}../../../../../">git</a> &raquo; <h1><a href="{{relroot}}../../../../../">git</a> &raquo;
<a href="{{relroot}}../../../">{{repo.name}}</a> &raquo; <a href="{{relroot}}../../../">{{repo.name}}</a> &raquo;
<a href="{{reltree}}../">{{repo.branch}}</a> &raquo; <a href="{{reltree}}../">{{branch}}</a> &raquo;
<a href="{{reltree}}">tree</a> <a href="{{reltree}}">tree</a>
</h1> </h1>
<h3> <h3>
<a href="{{reltree}}">[{{repo.branch}}]</a> / <a href="{{reltree}}">[{{branch}}]</a> /
% base = smstr(reltree) % base = smstr(reltree)
% for c in dirname.split('/'): % for c in dirname.split('/'):
% if not c.raw: % if not c.raw: