diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2015-01-14 08:46:33 +0100 |
---|---|---|
committer | Alberto Bertogli <albertito@blitiri.com.ar> | 2015-01-17 14:11:39 +0100 |
commit | 37e731fc2ebe5d249ea9caa85e15491654450238 (patch) | |
tree | 1426065dfd53cf26169eb9ad695ebbcae1e45d91 /git-arr | |
parent | e6099cf2729fc446f7cba2dab5da2d6b0646b567 (diff) | |
download | git-arr-fork-37e731fc2ebe5d249ea9caa85e15491654450238.zip |
blob: 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>
Diffstat (limited to 'git-arr')
-rwxr-xr-x | git-arr | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -231,8 +231,6 @@ def commit(repo, cid): @bottle.view('blob') @with_utils def blob(repo, bname, fname, dirname = ''): - r = repo.new_in_branch(bname) - if dirname and not dirname.endswith('/'): dirname = dirname + '/' @@ -240,11 +238,12 @@ def blob(repo, bname, fname, dirname = ''): fname = git.smstr.from_url(fname) path = dirname.raw + fname.raw - content = r.blob(path) + content = repo.blob(path, bname) if content is None: bottle.abort(404, "File %r not found in branch %s" % (path, bname)) - return dict(repo = r, dirname = dirname, fname = fname, blob = content) + return dict(repo = repo, branch = bname, dirname = dirname, fname = fname, + blob = content) @bottle.route('/r/<repo:repo>/b/<bname:path>/t/') @bottle.route('/r/<repo:repo>/b/<bname:path>/t/<dirname:path>/') |