From 37e731fc2ebe5d249ea9caa85e15491654450238 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Wed, 14 Jan 2015 02:46:33 -0500 Subject: 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 Signed-off-by: Alberto Bertogli --- git-arr | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'git-arr') diff --git a/git-arr b/git-arr index ce8ef30..15dbf14 100755 --- a/git-arr +++ b/git-arr @@ -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//b//t/') @bottle.route('/r//b//t//') -- cgit v1.2.3