aboutsummaryrefslogtreecommitdiffstats
path: root/bn_django/git_browse/models.py
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 /bn_django/git_browse/models.py
parent10683070288b879057b70bea56fca96373cb506c (diff)
downloadbnewnet-a891065a0447396a89fd03e4f038ca2e996a68aa.tar.gz
bnewnet-a891065a0447396a89fd03e4f038ca2e996a68aa.zip
fixed tree browsing in git_browse, and diff output for commits
Diffstat (limited to 'bn_django/git_browse/models.py')
-rw-r--r--bn_django/git_browse/models.py35
1 files changed, 33 insertions, 2 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'