Esempio n. 1
0
    def test_writing(self, path):
        NULL_BIN_SHA = '\0' * 20

        alt_path = os.path.join(path, 'alternates')
        rdb = ReferenceDB(alt_path)
        assert len(rdb.databases()) == 0
        assert rdb.size() == 0
        assert len(list(rdb.sha_iter())) == 0

        # try empty, non-existing
        assert not rdb.has_object(NULL_BIN_SHA)

        # setup alternate file
        # add two, one is invalid
        own_repo_path = fixture_path('../../../.git/objects')  # use own repo
        self.make_alt_file(alt_path, [own_repo_path, "invalid/path"])
        rdb.update_cache()
        assert len(rdb.databases()) == 1

        # we should now find a default revision of ours
        gitdb_sha = hex_to_bin("5690fd0d3304f378754b23b098bd7cb5f4aa1976")
        assert rdb.has_object(gitdb_sha)

        # remove valid
        self.make_alt_file(alt_path, ["just/one/invalid/path"])
        rdb.update_cache()
        assert len(rdb.databases()) == 0

        # add valid
        self.make_alt_file(alt_path, [own_repo_path])
        rdb.update_cache()
        assert len(rdb.databases()) == 1
Esempio n. 2
0
    def test_writing(self, path):
        alt_path = os.path.join(path, 'alternates')
        rdb = ReferenceDB(alt_path)
        assert len(rdb.databases()) == 0
        assert rdb.size() == 0
        assert len(list(rdb.sha_iter())) == 0

        # try empty, non-existing
        assert not rdb.has_object(NULL_BIN_SHA)

        # setup alternate file
        # add two, one is invalid
        own_repo_path = fixture_path('../../../.git/objects')       # use own repo
        self.make_alt_file(alt_path, [own_repo_path, "invalid/path"])
        rdb.update_cache()
        assert len(rdb.databases()) == 1

        # we should now find a default revision of ours
        gitdb_sha = hex_to_bin("5690fd0d3304f378754b23b098bd7cb5f4aa1976")
        assert rdb.has_object(gitdb_sha)

        # remove valid
        self.make_alt_file(alt_path, ["just/one/invalid/path"])
        rdb.update_cache()
        assert len(rdb.databases()) == 0

        # add valid
        self.make_alt_file(alt_path, [own_repo_path])
        rdb.update_cache()
        assert len(rdb.databases()) == 1
Esempio n. 3
0
    def test_writing(self, path):
        alt_path = os.path.join(path, 'alternates')
        rdb = ReferenceDB(alt_path)
        assert len(rdb.databases()) == 0
        assert rdb.size() == 0
        assert len(list(rdb.sha_iter())) == 0

        # try empty, non-existing
        assert not rdb.has_object(NULL_BIN_SHA)

        # setup alternate file
        # add two, one is invalid
        own_repo_path = os.path.join(self.gitrepopath,
                                     'objects')  # use own repo
        self.make_alt_file(alt_path, [own_repo_path, "invalid/path"])
        rdb.update_cache()
        assert len(rdb.databases()) == 1

        # we should now find a default revision of ours
        gitdb_sha = next(rdb.sha_iter())
        assert rdb.has_object(gitdb_sha)

        # remove valid
        self.make_alt_file(alt_path, ["just/one/invalid/path"])
        rdb.update_cache()
        assert len(rdb.databases()) == 0

        # add valid
        self.make_alt_file(alt_path, [own_repo_path])
        rdb.update_cache()
        assert len(rdb.databases()) == 1