示例#1
0
 def addTree(self, tree, path, snapshot):
     """
     Recursively traverses the git tree
     """
     # todo: don't add metadir to assets
     for entry in tree:
         try:
             obj = self.repo[entry.id]
         except:
             print "bad id?", entry.id
             continue
         if obj.type == GIT_OBJ_TREE:
             self.addTree(obj, os.path.join(path, entry.name), snapshot)
         elif obj.type == GIT_OBJ_BLOB:
             name = os.path.join(path, entry.name)
             if name in self.assets:
                 asset = self.assets[name]
                 asset.addVersion(snapshot.commit.id, obj.id)
             else:
                 xid = genxid(snapshot.commit.id, obj.id)
                 asset = Asset()
                 asset.configure(snapshot.commit.id, obj.id, xid, name,
                                 self.repoDir)
                 self.assets[name] = asset
             snapshot.add(asset)
示例#2
0
文件: guild.py 项目: Nomicoin/viki
 def genxid(self):
     """
     The project xid is generated from the first commit and tree sha's
     """
     walker = self.repo.walk(self.repo.head.target, GIT_SORT_TIME | GIT_SORT_REVERSE)
     commit = walker.next()
     xid = genxid(commit.id, commit.tree.id)
     return str(xid)
示例#3
0
 def genxid(self):
     """
     The project xid is generated from the first commit and tree sha's
     """
     walker = self.repo.walk(self.repo.head.target,
                             GIT_SORT_TIME | GIT_SORT_REVERSE)
     commit = walker.next()
     xid = genxid(commit.id, commit.tree.id)
     return str(xid)
示例#4
0
文件: guild.py 项目: Nomicoin/viki
 def addTree(self, tree, path, snapshot):
     """
     Recursively traverses the git tree
     """
     # todo: don't add metadir to assets
     for entry in tree:
         try:
             obj = self.repo[entry.id]
         except:
             print "bad id?", entry.id
             continue
         if obj.type == GIT_OBJ_TREE:
             self.addTree(obj, os.path.join(path, entry.name), snapshot)
         elif obj.type == GIT_OBJ_BLOB:
             name = os.path.join(path, entry.name)
             if name in self.assets:
                 asset = self.assets[name]
                 asset.addVersion(snapshot.commit.id, obj.id)
             else:
                 xid = genxid(snapshot.commit.id, obj.id)
                 asset = Asset()
                 asset.configure(snapshot.commit.id, obj.id, xid, name, self.repoDir)
                 self.assets[name] = asset
             snapshot.add(asset)