def test_get_object_size(): tmp = maketemp() commands.init_bare(tmp) sha1 = commands.write_object(repo=tmp, content='FOO') eq(sha1, 'd96c7efbfec2814ae0301ad054dc8d9fc416c9b5') got = commands.get_object_size(repo=tmp, object=sha1) eq(got, 3)
def stat(self): if self.path == "": return posix.stat_result([stat.S_IFDIR + 0777, 0, 0, 0, 0, 0, 0, 0, 0, 0]) for data in commands.ls_files(repo=self.repo, index=self.index, path=self.path, children=False): if data["path"] == self.path: mode = int(data["mode"], 8) size = commands.get_object_size(repo=self.repo, object=data["object"]) return posix.stat_result([mode, 0, 0, 0, 0, 0, size, 0, 0, 0]) else: # if current path has children, it must be a dir assert data["path"].startswith(self.path + "/") return posix.stat_result([stat.S_IFDIR + 0777, 0, 0, 0, 0, 0, 0, 0, 0, 0]) # not found raise OSError(errno.ENOENT, os.strerror(errno.ENOENT))
def size(self): if self.path == '': object = commands.rev_parse( repo=self.repo, rev='%s^{tree}' % self.rev, ) for data in commands.ls_tree( repo=self.repo, path=self.path, treeish=self.rev, children=False, ): object = data['object'] break return commands.get_object_size( repo=self.repo, object=object, )
def size(self): object = self.git_get_sha1() # it exists return commands.get_object_size(repo=self.repo, object=object)