diff options
Diffstat (limited to 'bn_django/git_browse/views.py')
-rw-r--r-- | bn_django/git_browse/views.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/bn_django/git_browse/views.py b/bn_django/git_browse/views.py index ed653df..f28aa76 100644 --- a/bn_django/git_browse/views.py +++ b/bn_django/git_browse/views.py @@ -9,6 +9,11 @@ import os, commands from models import * try: + GITBROWSE_BASE = settings.GITBROWSE_BASE+'/' +except AttributeError: + GITBROWSE_BASE='/home/' + +try: GITCOMMAND = settings.GITCOMMAND except AttributeError: GITCOMMAND='git' @@ -36,9 +41,11 @@ def view_tree(request, repo, hash=None,branch=None): (GITPREFIX, heads, tags) = therepo.scan() if(hash == None): - head_ref = commands.getoutput('cd ' + therepo.path + '; cat HEAD') + head_ref = commands.getoutput('cd ' + GITBROWSE_BASE \ + + therepo.slug +'/.git; cat HEAD') head_ref = head_ref.split()[1] - hash = commands.getoutput('cd ' + therepo.path + '; cat ' + head_ref) + hash = commands.getoutput('cd ' + GITBROWSE_BASE + therepo.slug \ + +'/.git; cat ' + head_ref) tree_ls = commands.getoutput(GITPREFIX + ' ls-tree ' + hash) tree_objs = list() @@ -63,6 +70,9 @@ def view_log(request, repo, hash=None): therepo = get_object_or_404(Repository, slug=repo) (GITPREFIX, heads, tags) = therepo.scan() + GITPREFIX = 'cd ' + GITBROWSE_BASE + therepo.slug + '; ' + GITCOMMAND \ + + ' --git-dir=' + GITBROWSE_BASE + therepo.slug + '/.git ' + logtxt = commands.getoutput(GITPREFIX + ' log | cat') log_items = logtxt.split('\ncommit ') if (log_items[0] == ''): @@ -116,6 +126,11 @@ def view_obj(request, repo, hash, branch=None): (GITPREFIX, heads, tags) = therepo.scan() obj_type = commands.getoutput(GITPREFIX + ' cat-file -t ' + hash) + #if(obj_type == 'tree'): + # redirect_to('../tree/' + hash); + #if(obj_type == 'blob'): + # redirect_to('../blob/' + hash); + obj_contents = commands.getoutput(GITPREFIX + ' cat-file -p ' + hash) obj_size = commands.getoutput(GITPREFIX + ' cat-file -s ' + hash) |