예제 #1
0
    def test_merged_revisions(self):
        repo = gitutils.GitProject(git.Repo.init(self.workdir))
        repo.commit('initial commit')
        repo.create_version('1.0.0')
        with repo.open('upstream.wrap', 'w') as f:
            ini.WrapFile(directory='hello',
                         source_url='https://example.com/file.tgz',
                         source_filename='file.tgz',
                         source_hash='hash-hash-hash').write(f)

        repo.commit('commit 1')
        wrap = wrapcreator.make_wrap('project', repo.git_dir, '1.0.0')
        self.assertEqual(wrap.revision, 1)

        comm2 = repo.commit('commit 2')
        wrap = wrapcreator.make_wrap('project', repo.git_dir, '1.0.0')
        self.assertEqual(wrap.revision, 2)

        repo.commit('commit 3')
        wrap = wrapcreator.make_wrap('project', repo.git_dir, '1.0.0')
        self.assertEqual(wrap.revision, 3)

        repo.merge_commit('commit 4', parent=comm2)
        wrap = wrapcreator.make_wrap('project', repo.git_dir, '1.0.0')
        self.assertEqual(wrap.revision, 4)

        repo.merge_commit('commit 5', parent=comm2)
        wrap = wrapcreator.make_wrap('project', repo.git_dir, '1.0.0')
        self.assertEqual(wrap.revision, 5)
예제 #2
0
    def test_make_wrap(self):
        repo = git.Repo.init(self.workdir)
        repo.index.commit('initial commit')
        repo.head.reference = repo.create_head('1.2.3')

        def gopen(path, mode='r'):
            return gitutils.GitFile.open(repo, path, mode)

        with gopen('upstream.wrap', 'w') as f:
            upstream.UpstreamWrap(directory='hello',
                                  source_url='https://example.com/file.tgz',
                                  source_filename='file.tgz',
                                  source_hash='hash-hash-hash').write(f)
        with gopen('meson.wrap', 'w') as f:
            f.write('hello world')
        repo.index.commit('my commit')
        wrap = wrapcreator.make_wrap('project', repo.git_dir, '1.2.3')
        up = upstream.UpstreamWrap.from_string(wrap.wrap)
        self.assertEqual(up.directory, 'hello')
        self.assertEqual(up.source_url, 'https://example.com/file.tgz')
        self.assertEqual(up.source_filename, 'file.tgz')
        self.assertEqual(up.source_hash, 'hash-hash-hash')
        self.assertEqual(
            up.patch_url, 'https://wrapdb.mesonbuild.com/v1/'
            'projects/project/1.2.3/1/get_zip')
        self.assertEqual(up.patch_filename, 'project-1.2.3-1-wrap.zip')
        with io.BytesIO(wrap.zip) as zipf:
            with zipfile.ZipFile(zipf, 'r') as zip:
                self.assertListEqual(zip.namelist(), ['hello/meson.wrap'])
                self.assertEqual(zip.read('hello/meson.wrap'), b'hello world')
        self.assertEqual(up.patch_hash, hashlib.sha256(wrap.zip).hexdigest())
        self.assertEqual(wrap.wrap_name, 'project-1.2.3-1-wrap.wrap')
        self.assertEqual(wrap.zip_name, 'project-1.2.3-1-wrap.zip')
예제 #3
0
 def test_make_wrap(self):
     repo = gitutils.GitProject(git.Repo.init(self.workdir))
     repo.commit('initial commit')
     repo.create_version('1.2.3')
     with repo.open('upstream.wrap', 'w') as f:
         ini.WrapFile(directory='hello',
                      source_url='https://example.com/file.tgz',
                      source_filename='file.tgz',
                      source_hash='hash-hash-hash').write(f)
     with repo.open('meson.wrap', 'w') as f:
         f.write('hello world')
     repo.commit('my commit')
     wrap = wrapcreator.make_wrap('project', repo.git_dir, '1.2.3')
     up = ini.WrapFile.from_string(wrap.wrapfile_content)
     self.assertEqual(up.directory, 'hello')
     self.assertEqual(up.source_url, 'https://example.com/file.tgz')
     self.assertEqual(up.source_filename, 'file.tgz')
     self.assertEqual(up.source_hash, 'hash-hash-hash')
     self.assertEqual(
         up.patch_url, 'https://wrapdb.mesonbuild.com/v1/'
         'projects/project/1.2.3/1/get_zip')
     self.assertEqual(up.patch_filename, 'project-1.2.3-1-wrap.zip')
     with io.BytesIO(wrap.zip) as zipf:
         with zipfile.ZipFile(zipf, 'r') as zip:
             self.assertListEqual(zip.namelist(), ['hello/meson.wrap'])
             self.assertEqual(zip.read('hello/meson.wrap'), b'hello world')
     self.assertEqual(up.patch_hash, hashlib.sha256(wrap.zip).hexdigest())
     self.assertEqual(wrap.wrapfile_name, 'project-1.2.3-1-wrap.wrap')
     self.assertEqual(wrap.zip_name, 'project-1.2.3-1-wrap.zip')
     self.assertEqual(wrap.commit_sha, repo.head_hexsha)
예제 #4
0
    def test_make_wrap(self):
        repo = git.Repo.init(self.workdir)
        repo.index.commit('initial commit')
        repo.head.reference = repo.create_head('1.2.3')

        def gopen(path, mode='r'):
            return gitutils.GitFile.open(repo, path, mode)

        with gopen('upstream.wrap', 'w') as f:
            upstream.UpstreamWrap(
                directory='hello',
                source_url='https://example.com/file.tgz',
                source_filename='file.tgz',
                source_hash='hash-hash-hash').write(f)
        with gopen('meson.wrap', 'w') as f:
            f.write('hello world')
        repo.index.commit('my commit')
        wrap = wrapcreator.make_wrap('project', repo.git_dir, '1.2.3')
        up = upstream.UpstreamWrap.from_string(wrap.wrap)
        self.assertEqual(up.directory, 'hello')
        self.assertEqual(up.source_url, 'https://example.com/file.tgz')
        self.assertEqual(up.source_filename, 'file.tgz')
        self.assertEqual(up.source_hash, 'hash-hash-hash')
        self.assertEqual(up.patch_url, 'https://wrapdb.mesonbuild.com/v1/'
                                       'projects/project/1.2.3/1/get_zip')
        self.assertEqual(up.patch_filename, 'project-1.2.3-1-wrap.zip')
        with io.BytesIO(wrap.zip) as zipf:
            with zipfile.ZipFile(zipf, 'r') as zip:
                self.assertListEqual(zip.namelist(), ['hello/meson.wrap'])
                self.assertEqual(zip.read('hello/meson.wrap'), b'hello world')
        self.assertEqual(up.patch_hash, hashlib.sha256(wrap.zip).hexdigest())
        self.assertEqual(wrap.wrap_name, 'project-1.2.3-1-wrap.wrap')
        self.assertEqual(wrap.zip_name, 'project-1.2.3-1-wrap.zip')
예제 #5
0
 def test_make_wrap_bad_wrapfile(self):
     repo = gitutils.GitProject(git.Repo.init(self.workdir))
     repo.commit('initial commit')
     repo.create_version('1.2.3')
     with repo.open('upstream.wrap', 'w') as f:
         f.write('[wrap-file]\n')
         f.write('hello = world\n')
     repo.commit('my commit')
     with self.assertRaisesRegex(RuntimeError,
                                 'Missing .* in upstream.wrap'):
         _ = wrapcreator.make_wrap('project', repo.git_dir, '1.2.3')
예제 #6
0
 def update_db(self, project_name, repo_url, branch):
     wrap = wrapcreator.make_wrap(project_name, repo_url, branch)
     self.db.insert(project_name, branch,
                    wrap.revision, wrap.wrap, wrap.zip)
예제 #7
0
 def publish(cls, organization: str, project: str, branch: str):
     gh_project = cls._get_project(organization, project)
     url = gh_project.clone_url
     wrap = wrapcreator.make_wrap(project, url, branch)
     # TODO actually publish
     raise NotImplementedError('does not publish yet')
예제 #8
0
 def publish(cls, organization: str, project: str, branch: str):
     ghrepo = environment.repo(organization, project)
     wrap = wrapcreator.make_wrap(project, ghrepo.clone_url, branch)
     with tempfile.TemporaryDirectory() as tmp:
         cls._import_wrap(tmp, organization, wrap)