aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@manus.(none)>2007-08-08 02:55:48 -0400
committerbnewbold <bnewbold@manus.(none)>2007-08-08 02:55:48 -0400
commita891065a0447396a89fd03e4f038ca2e996a68aa (patch)
tree1fdc6a809fc96ddc7cfef5b3bbe82b55dddf7bca
parent10683070288b879057b70bea56fca96373cb506c (diff)
downloadbnewnet-a891065a0447396a89fd03e4f038ca2e996a68aa.tar.gz
bnewnet-a891065a0447396a89fd03e4f038ca2e996a68aa.zip
fixed tree browsing in git_browse, and diff output for commits
-rw-r--r--bn_django/git_browse/models.py35
-rw-r--r--bn_django/git_browse/templates/git_browse/tree_table4
-rw-r--r--bn_django/git_browse/views.py16
-rw-r--r--bn_django/git_wiki/models.py2
4 files changed, 51 insertions, 6 deletions
diff --git a/bn_django/git_browse/models.py b/bn_django/git_browse/models.py
index c914cac..2af2c98 100644
--- a/bn_django/git_browse/models.py
+++ b/bn_django/git_browse/models.py
@@ -106,6 +106,37 @@ class Tree(models.Model):
def get_admin_url(self):
return "%s/code/tree/%s/" % (ADMIN_URL, self.id)
+ def update(self):
+ import commands
+ if (not self.id): return
+
+ self.id = self.id.strip()
+ tree_ls = commands.getoutput(GITPREFIX + ' ls-tree --full-name ' \
+ + self.id)
+ tree_objs = list()
+ blob_objs = list()
+ for line in tree_ls.splitlines():
+ l = line.split()
+ if len(l) < 4:
+ continue
+ if l[1] == 'tree':
+ t = Tree(id=l[2])
+ t.path = ' '.join(l[3:])
+ if self.path and self.path != '/':
+ t.path = self.path + '/' + t.path
+ t.name = t.path
+ tree_objs.append(t)
+ if l[1] == 'blob':
+ i = Item(id=l[2])
+ i.path = ' '.join(l[3:])
+ if self.path and self.path != '/':
+ i.path = self.path + '/' + i.path
+ i.name=i.path
+ blob_objs.append(i)
+ self.tree_objs = tree_objs
+ self.blob_objs = blob_objs
+ self.all_objs = tree_objs + blob_objs
+
def tree_from_str(s):
s = s.split();
if len(s) != 4: return
@@ -183,8 +214,6 @@ class Commit(models.Model):
self.id = self.id.strip()
raw = commands.getoutput(GITPREFIX + ' cat-file -p ' + self.id)
- self.rawdiff = commands.getoutput(GITPREFIX + ' diff ' + self.id \
- +' | cat')
raw = raw.splitlines()
if len(raw) < 3: return
@@ -196,6 +225,8 @@ class Commit(models.Model):
self.author_date = time.ctime(int(raw[2].split()[-2]))
self.committer = raw[3].split()[1]
self.committer_date = time.ctime(int(raw[3].split()[-2]))
+ self.rawdiff = commands.getoutput(GITPREFIX + ' diff ' \
+ + self.parenthash + ' ' + self.id + ' | cat')
if len(raw) > 4:
for l in raw[4:]:
self.comment += str(l) + '\n'
diff --git a/bn_django/git_browse/templates/git_browse/tree_table b/bn_django/git_browse/templates/git_browse/tree_table
index a472283..7f67fe9 100644
--- a/bn_django/git_browse/templates/git_browse/tree_table
+++ b/bn_django/git_browse/templates/git_browse/tree_table
@@ -1,6 +1,6 @@
-{% if tree_objs %}
+{% if all_objs %}
<table class="gitbrowser">
- {% for o in tree_objs %}
+ {% for o in all_objs %}
<tr> <td class="objtype">
{{o.type}}</td>
<td class="filemode">
diff --git a/bn_django/git_browse/views.py b/bn_django/git_browse/views.py
index e953d26..1f1b03c 100644
--- a/bn_django/git_browse/views.py
+++ b/bn_django/git_browse/views.py
@@ -48,9 +48,21 @@ def view_tree(request, repo, hash=None,branch=None):
if len(l) < 4:
continue
if l[1] == 'tree':
- tree_objs.append(tree_from_str(line))
+ t = Tree(id=l[2])
+ t.path = ' '.join(l[3:])
+ #if self.path and self.path != '/':
+ # t.path = self.path + '/' + t.path
+ t.name = t.path
+ t.type = 'tree'
+ tree_objs.append(t)
if l[1] == 'blob':
- tree_objs.append(blob_from_str(line))
+ i = Blob(id=l[2])
+ i.path = ' '.join(l[3:])
+ #if self.path and self.path != '/':
+ # i.path = self.path + '/' + i.path
+ i.name=i.path
+ i.type = 'blob'
+ blob_objs.append(i)
return render_to_response('git_browse/tree.html',
dict(object=therepo,
diff --git a/bn_django/git_wiki/models.py b/bn_django/git_wiki/models.py
index f0a7e9c..83a275b 100644
--- a/bn_django/git_wiki/models.py
+++ b/bn_django/git_wiki/models.py
@@ -151,6 +151,8 @@ class Commit(models.Model):
self.author_date = time.ctime(int(raw[1].split()[-2]))
self.committer = raw[2].split()[1]
self.committer_date = time.ctime(int(raw[2].split()[-2]))
+ self.rawdiff = commands.getoutput(GITPREFIX + ' diff ' \
+ + self.parenthash + ' ' + self.id + ' | cat')
if len(raw) > 3:
for l in raw[3:]:
self.comment += str(l) + '\n'