diff options
author | bnewbold <bnewbold@manus.(none)> | 2007-02-20 02:21:25 -0800 |
---|---|---|
committer | bnewbold <bnewbold@manus.(none)> | 2007-02-20 02:21:25 -0800 |
commit | 3d203c153301d4dd9c3285e7dea86ee09eb3b0c5 (patch) | |
tree | 47bf5bb676c5f25def0a4a37852c1783961a03e6 /bn_django/git_browse/views.py | |
parent | 566473abe7aac915429a633e996bdb719f1a308b (diff) | |
download | bnewnet-3d203c153301d4dd9c3285e7dea86ee09eb3b0c5.tar.gz bnewnet-3d203c153301d4dd9c3285e7dea86ee09eb3b0c5.zip |
mid-progress, work on git-browser
fan is dying, more work to do though!
TODO: seperate style for git_browser, use "block.super"
Diffstat (limited to 'bn_django/git_browse/views.py')
-rw-r--r-- | bn_django/git_browse/views.py | 33 |
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)) |