Exemplo n.º 1
0
    def __init__(self, root, conf):
        """Init a Git bare Repository on top of a Swift container.

        References are managed in info/refs objects by
        `SwiftInfoRefsContainer`. The root attribute is the Swift
        container that contain the Git bare repository.

        Args:
          root: The container which contains the bare repo
          conf: A ConfigParser object
        """
        self.root = root.lstrip("/")
        self.conf = conf
        self.scon = SwiftConnector(self.root, self.conf)
        objects = self.scon.get_container_objects()
        if not objects:
            raise Exception("There is not any GIT repo here : %s" % self.root)
        objects = [o["name"].split("/")[0] for o in objects]
        if OBJECTDIR not in objects:
            raise Exception("This repository (%s) is not bare." % self.root)
        self.bare = True
        self._controldir = self.root
        object_store = SwiftObjectStore(self.scon)
        refs = SwiftInfoRefsContainer(self.scon, object_store)
        BaseRepo.__init__(self, object_store, refs)
 def __init__(self, redis, prefix):
     BaseRepo.__init__(self,
                       RedisObjectStore(redis, prefix),
                       RedisDictRefsContainer(redis, prefix))
     self._named_files = Dict(redis=redis, pickler=cPickle,
                              key='{0:s}:named_files'.format('prefix'))
     self._config = ConfigFile()
     self.bare = True
 def __init__(self, redis, prefix):
     BaseRepo.__init__(self, RedisObjectStore(redis, prefix),
                       RedisDictRefsContainer(redis, prefix))
     self._named_files = Dict(redis=redis,
                              pickler=cPickle,
                              key='{0:s}:named_files'.format('prefix'))
     self._config = ConfigFile()
     self.bare = True
Exemplo n.º 4
0
 def __init__(self, RepoName):
     repo = Repositories.get_by_key_name(RepoName)
     if repo:
         self.REPO_NAME = RepoName
         self.REPO = Repositories.get_by_key_name(self.REPO_NAME)
         self.Bare = True
         object_store = ObjectStore(self.REPO)
         refs_container = RefsContainer(self.REPO)
         BaseRepo.__init__(self, object_store, refs_container)
     else:
         raise NotGitRepository(RepoName)
Exemplo n.º 5
0
 def __init__(self, RepoName):
     repo = Repositories.get_by_key_name(RepoName)
     if repo:
         self.REPO_NAME = RepoName
         self.REPO = Repositories.get_by_key_name(self.REPO_NAME)
         self.Bare = True
         object_store = ObjectStore(self.REPO)
         refs_container = RefsContainer(self.REPO)
         BaseRepo.__init__(self, object_store, refs_container)
     else:
         raise NotGitRepository(RepoName)
Exemplo n.º 6
0
    def test_get_info_packs(self):
        class TestPack(object):
            def __init__(self, sha):
                self._sha = sha

            def name(self):
                return self._sha

        packs = [TestPack(str(i) * 40) for i in xrange(1, 4)]

        class TestObjectStore(MemoryObjectStore):
            # property must be overridden, can't be assigned
            @property
            def packs(self):
                return packs

        store = TestObjectStore()
        repo = BaseRepo(store, None)
        backend = DictBackend({'/': repo})
        mat = re.search('.*', '//info/packs')
        output = ''.join(get_info_packs(self._req, backend, mat))
        expected = 'P pack-%s.pack\n' * 3
        expected %= ('1' * 40, '2' * 40, '3' * 40)
        self.assertEquals(expected, output)
        self.assertEquals(HTTP_OK, self._status)
        self.assertContentTypeEquals('text/plain')
        self.assertFalse(self._req.cached)
Exemplo n.º 7
0
    def test_get_info_packs(self):
        class TestPackData(object):
            def __init__(self, sha):
                self.filename = "pack-%s.pack" % sha

        class TestPack(object):
            def __init__(self, sha):
                self.data = TestPackData(sha)

        packs = [TestPack(str(i) * 40) for i in range(1, 4)]

        class TestObjectStore(MemoryObjectStore):
            # property must be overridden, can't be assigned
            @property
            def packs(self):
                return packs

        store = TestObjectStore()
        repo = BaseRepo(store, None)
        backend = DictBackend({'/': repo})
        mat = re.search('.*', '//info/packs')
        output = b''.join(get_info_packs(self._req, backend, mat))
        expected = b''.join([(b'P pack-' + s + b'.pack\n')
                             for s in [b'1' * 40, b'2' * 40, b'3' * 40]])
        self.assertEqual(expected, output)
        self.assertEqual(HTTP_OK, self._status)
        self.assertContentTypeEquals('text/plain')
        self.assertFalse(self._req.cached)
Exemplo n.º 8
0
    def __init__(self, root, conf):
        """Init a Git bare Repository on top of a Swift container.

        References are managed in info/refs objects by
        `SwiftInfoRefsContainer`. The root attribute is the Swift
        container that contain the Git bare repository.

        :param root: The container which contains the bare repo
        :param conf: A ConfigParser object
        """
        self.root = root.lstrip('/')
        self.conf = conf
        self.scon = SwiftConnector(self.root, self.conf)
        objects = self.scon.get_container_objects()
        if not objects:
            raise Exception('There is not any GIT repo here : %s' % self.root)
        objects = [o['name'].split('/')[0] for o in objects]
        if OBJECTDIR not in objects:
            raise Exception('This repository (%s) is not bare.' % self.root)
        self.bare = True
        self._controldir = self.root
        object_store = SwiftObjectStore(self.scon)
        refs = SwiftInfoRefsContainer(self.scon, object_store)
        BaseRepo.__init__(self, object_store, refs)
Exemplo n.º 9
0
	def __init__(self):
		BaseRepo.__init__(self, ObjectStore(), DictRefsContainer({}))
		self._named_files = {}
		self.bare = True
Exemplo n.º 10
0
 def __init__(self, name):
     self._name = name
     BaseRepo.__init__(self, MysqlObjectStore(name),
                       MysqlRefsContainer(name))
     self.bare = True
Exemplo n.º 11
0
 def __init__(self, name):
     self._name = name
     BaseRepo.__init__(self, MysqlObjectStore(name),
                       MysqlRefsContainer(name))
     self.bare = True