diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2015-01-14 08:46:32 +0100 |
---|---|---|
committer | Alberto Bertogli <albertito@blitiri.com.ar> | 2015-01-17 14:11:27 +0100 |
commit | e6099cf2729fc446f7cba2dab5da2d6b0646b567 (patch) | |
tree | 157df3e9e4021f07c2864aa55c3a5f151a93421d | |
parent | 46640c68b9758b3c76d6a81d5a7c8601b6c4b5ee (diff) | |
download | git-arr-fork-e6099cf2729fc446f7cba2dab5da2d6b0646b567.zip |
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>
-rwxr-xr-x | git-arr | 4 | ||||
-rw-r--r-- | views/tree.html | 8 |
2 files changed, 6 insertions, 6 deletions
@@ -256,8 +256,8 @@ def tree(repo, bname, dirname = ''): dirname = git.smstr.from_url(dirname) - r = repo.new_in_branch(bname) - return dict(repo = r, tree = r.tree(), dirname = dirname) + return dict(repo = repo, branch = bname, tree = repo.tree(bname), + dirname = dirname) @bottle.route('/r/<repo:repo>/b/<bname:path>/') @bottle.route('/r/<repo:repo>/b/<bname:path>/<offset:int>.html') diff --git a/views/tree.html b/views/tree.html index f983b75..68a5844 100644 --- a/views/tree.html +++ b/views/tree.html @@ -8,10 +8,10 @@ % else: % reltree = '../' * (len(dirname.split('/')) - 1) % end -% relroot = reltree + '../' * (len(repo.branch.split('/')) - 1) +% relroot = reltree + '../' * (len(branch.split('/')) - 1) <title>git » {{repo.name}} » - {{repo.branch}} » {{dirname.unicode}}</title> + {{branch}} » {{dirname.unicode}}</title> <link rel="stylesheet" type="text/css" href="{{relroot}}../../../../../static/git-arr.css"/> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> @@ -20,12 +20,12 @@ <body class="tree"> <h1><a href="{{relroot}}../../../../../">git</a> » <a href="{{relroot}}../../../">{{repo.name}}</a> » - <a href="{{reltree}}../">{{repo.branch}}</a> » + <a href="{{reltree}}../">{{branch}}</a> » <a href="{{reltree}}">tree</a> </h1> <h3> - <a href="{{reltree}}">[{{repo.branch}}]</a> / + <a href="{{reltree}}">[{{branch}}]</a> / % base = smstr(reltree) % for c in dirname.split('/'): % if not c.raw: |