diff options
Diffstat (limited to 'bn_django/git_browse/models.py')
-rw-r--r-- | bn_django/git_browse/models.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/bn_django/git_browse/models.py b/bn_django/git_browse/models.py index db69bfc..edddf60 100644 --- a/bn_django/git_browse/models.py +++ b/bn_django/git_browse/models.py @@ -119,6 +119,8 @@ class Blob(models.Model): path = models.CharField("relative path from repo base", maxlength=512) id = models.CharField("hash", maxlength=40,blank=False,primary_key=True) name = models.CharField("name of dir", maxlength=128,blank=False) + size = models.IntField("filesize in byte", maxlength=128,blank=False) + contents = models.TextField("ASCII contents of the file") type='blob' class Admin: @@ -130,6 +132,16 @@ class Blob(models.Model): return "/code/%s/%s" % (self.repo.slug, self.hash) 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() + self.contents = commands.getoutput(GITPREFIX + ' cat-file -p ' + self.id) + self.size = commands.getoutput(GITPREFIX + ' cat-file -s ' + hash) + + def blob_from_str(s): s = s.split(); |