aboutsummaryrefslogtreecommitdiffstats
path: root/bn_django/git_browse/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'bn_django/git_browse/views.py')
-rw-r--r--bn_django/git_browse/views.py33
1 files changed, 19 insertions, 14 deletions
diff --git a/bn_django/git_browse/views.py b/bn_django/git_browse/views.py
index c8a7a40..d8e01d7 100644
--- a/bn_django/git_browse/views.py
+++ b/bn_django/git_browse/views.py
@@ -23,26 +23,29 @@ except AttributeError:
def repo_info(request, repo,branch=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 '
-
- shortlog = commands.getoutput(GITPREFIX + ' log | ' + GITCOMMAND + '-shortlog')
+ shortlog = commands.getoutput(GITPREFIX + ' log | ' + GITCOMMAND \
+ + '-shortlog')
+ branches = commands.getoutput(GITPREFIX + ' branch')
filelist = commands.getoutput(GITPREFIX + ' ls-files')
-
- return render_to_response('git_browse/repository_info.html',
- dict(object=therepo,
- filelist=filelist,
+ return render_to_response('git_browse/repository_info.html', \
+ dict(object=therepo, \
+ filelist=filelist, \
+ tags=tags, \
+ heads=heads, \
shortlog=shortlog,))
def view_tree(request, repo, hash=None,branch=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 '
-
if(hash == None):
- head_ref = commands.getoutput('cd ' + GITBROWSE_BASE + therepo.slug +'/.git; cat HEAD')
+ head_ref = commands.getoutput('cd ' + GITBROWSE_BASE \
+ + therepo.slug +'/.git; cat HEAD')
head_ref = head_ref.split()[1]
- hash = commands.getoutput('cd ' + GITBROWSE_BASE + therepo.slug +'/.git; 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()
@@ -65,8 +68,10 @@ def view_tree(request, repo, hash=None,branch=None):
def view_log(request, repo, tree_hash=None, branch=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 '
+ 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 ')
@@ -94,8 +99,8 @@ def view_log(request, repo, tree_hash=None, branch=None):
def view_obj(request, repo, hash, branch=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 '
obj_type = commands.getoutput(GITPREFIX + ' cat-file -t ' + hash)
#if(obj_type == 'tree'):
# redirect_to('../tree/' + hash);
@@ -109,5 +114,5 @@ def view_obj(request, repo, hash, branch=None):
dict(object=therepo,
hash=hash,
type=obj_type,
- size=float(obj_size)/1024.0,
+ size=float(obj_size),
contents=obj_contents))