def test_misc_options(self): """Test various options of git-import-srpm""" srpm = os.path.join(DATA_DIR, 'gbp-test2-2.0-0.src.rpm') eq_(mock_import(['--no-pristine-tar', '--packaging-branch=pack', '--upstream-branch=orig', '--packaging-dir=packaging', '--packaging-tag=ver_%(upstreamversion)s-rel_%(release)s', '--upstream-tag=orig/%(upstreamversion)s', '--author-is-committer', srpm]), 0) # Check repository state repo = GitRepository('gbp-test2') files = {'Makefile', 'README', 'dummy.sh', 'packaging/bar.tar.gz', 'packaging/foo.txt', 'packaging/gbp-test2.spec', 'packaging/gbp-test2-alt.spec', 'packaging/my.patch', 'packaging/my2.patch', 'packaging/my3.patch'} self._check_repo_state(repo, 'pack', ['pack', 'orig'], files) eq_(len(repo.get_commits()), 2) # Check packaging dir eq_(len(repo.get_commits(paths='packaging')), 1) # Check tags tags = repo.get_tags() eq_(set(tags), set(['orig/2.0', 'ver_2.0-rel_0'])) # Check git committer/author info = repo.get_commit_info('pack') eq_(info['author'].name, 'Markus Lehtonen') eq_(info['author'].email, '*****@*****.**') eq_(info['author'].name, info['committer'].name) eq_(info['author'].email, info['committer'].email)
def test_misc_options(self): """Test various options of git-import-srpm""" srpm = os.path.join(DATA_DIR, 'gbp-test2-2.0-0.src.rpm') eq_( mock_import([ '--no-patch-import', '--packaging-branch=pack', '--upstream-branch=orig', '--packaging-dir=packaging', '--packaging-tag=ver_%(upstreamversion)s-rel_%(release)s', '--upstream-tag=orig/%(upstreamversion)s', '--author-is-committer', srpm ]), 0) # Check repository state repo = GitRepository('gbp-test2') files = set([ 'Makefile', 'README', 'dummy.sh', 'packaging/bar.tar.gz', 'packaging/foo.txt', 'packaging/gbp-test2.spec', 'packaging/gbp-test2-alt.spec', 'packaging/my.patch', 'packaging/my2.patch', 'packaging/my3.patch' ]) self._check_repo_state(repo, 'pack', ['pack', 'orig'], files) eq_(len(repo.get_commits()), 2) # Check packaging dir eq_(len(repo.get_commits(paths='packaging')), 1) # Check tags tags = repo.get_tags() eq_(set(tags), set(['orig/2.0', 'ver_2.0-rel_0'])) # Check git committer/author info = repo.get_commit_info('pack') eq_(info['author'].name, 'Markus Lehtonen') eq_(info['author'].email, '*****@*****.**') eq_(info['author'].name, info['committer'].name) eq_(info['author'].email, info['committer'].email)
def test_misc_options(self): """Test various options of git-import-srpm""" srpm = os.path.join(DATA_DIR, 'gbp-test2-2.0-0.src.rpm') eq_( mock_import([ '--no-pristine-tar', '--packaging-branch=pack', '--upstream-branch=orig', '--packaging-dir=packaging', '--packaging-tag=ver_%(upstreamversion)s-rel_%(release)s', '--upstream-tag=orig/%(upstreamversion)s', '--author-is-committer', srpm ]), 0) # Check repository state repo = GitRepository('gbp-test2') files = { 'Makefile', 'README', 'dummy.sh', 'packaging/bar.tar.gz', 'packaging/foo.txt', 'packaging/gbp-test2.spec', 'packaging/gbp-test2-alt.spec', 'packaging/my.patch', 'packaging/my2.patch', 'packaging/my3.patch' } self._check_repo_state(repo, 'pack', ['pack', 'orig'], files) eq_(len(repo.get_commits()), 2) # Check packaging dir eq_(len(repo.get_commits(paths='packaging')), 1) # Check tags tags = repo.get_tags() eq_(set(tags), set(['orig/2.0', 'ver_2.0-rel_0'])) # Check git committer/author info = repo.get_commit_info('pack') eq_(info['author'].name, 'Markus Lehtonen') eq_(info['author'].email, '*****@*****.**') eq_(info['author'].name, info['committer'].name) eq_(info['author'].email, info['committer'].email) # Create a new commit by committing an empty tree commit = repo.commit_tree('4b825dc642cb6eb9a060e54bf8d69288fbee4904', msg="Empty commit", parents=[]) repo.create_tag('foo/1.0', msg="New tag", commit=commit) # Just blindly import another package on top of this to test more options os.chdir('gbp-test2') srpm = os.path.join(DATA_DIR, 'gbp-test-1.0-1.src.rpm') eq_( mock_import([ '--upstream-vcs-tag=foo/%(version)s', '--upstream-branch=orig', '--packaging-branch=pack', srpm ]), 0) parents = repo.get_commits(until='orig', num=1, options='--format=%P')[0].split() eq_(len(parents), 2) ok_(commit in parents) ok_(repo.rev_parse('orig/2.0^{}') in parents)
def test_misc_options(self): """Test various options of git-import-srpm""" srpm = os.path.join(DATA_DIR, 'gbp-test2-2.0-0.src.rpm') eq_(mock_import(['--no-pristine-tar', '--packaging-branch=pack', '--upstream-branch=orig', '--packaging-dir=packaging', '--packaging-tag=ver_%(upstreamversion)s-rel_%(release)s', '--upstream-tag=orig/%(upstreamversion)s', '--author-is-committer', srpm]), 0) # Check repository state repo = GitRepository('gbp-test2') files = {'Makefile', 'README', 'dummy.sh', 'packaging/bar.tar.gz', 'packaging/foo.txt', 'packaging/gbp-test2.spec', 'packaging/gbp-test2-alt.spec', 'packaging/my.patch', 'packaging/my2.patch', 'packaging/my3.patch'} self._check_repo_state(repo, 'pack', ['pack', 'orig'], files) eq_(len(repo.get_commits()), 2) # Check packaging dir eq_(len(repo.get_commits(paths='packaging')), 1) # Check tags tags = repo.get_tags() eq_(set(tags), set(['orig/2.0', 'ver_2.0-rel_0'])) # Check git committer/author info = repo.get_commit_info('pack') eq_(info['author'].name, 'Markus Lehtonen') eq_(info['author'].email, '*****@*****.**') eq_(info['author'].name, info['committer'].name) eq_(info['author'].email, info['committer'].email) # Create a new commit by committing an empty tree commit = repo.commit_tree('4b825dc642cb6eb9a060e54bf8d69288fbee4904', msg="Empty commit", parents=[]) repo.create_tag('foo/1.0', msg="New tag", commit=commit) # Just blindly import another package on top of this to test more options os.chdir('gbp-test2') srpm = os.path.join(DATA_DIR, 'gbp-test-1.0-1.src.rpm') eq_(mock_import(['--upstream-vcs-tag=foo/%(version)s', '--upstream-branch=orig', '--packaging-branch=pack', srpm]), 0) parents = repo.get_commits(until='orig', num=1, options='--format=%P')[0].split() eq_(len(parents), 2) ok_(commit in parents) ok_(repo.rev_parse('orig/2.0^{}') in parents)
def test_misc_options(self): """Test various options of git-import-srpm""" srpm = os.path.join(DATA_DIR, "gbp-test2-2.0-0.src.rpm") eq_( mock_import( [ "--no-pristine-tar", "--packaging-branch=pack", "--upstream-branch=orig", "--packaging-dir=packaging", "--packaging-tag=ver_%(upstreamversion)s-rel_%(release)s", "--upstream-tag=orig/%(upstreamversion)s", "--author-is-committer", srpm, ] ), 0, ) # Check repository state repo = GitRepository("gbp-test2") files = { "Makefile", "README", "dummy.sh", "packaging/bar.tar.gz", "packaging/foo.txt", "packaging/gbp-test2.spec", "packaging/gbp-test2-alt.spec", "packaging/my.patch", "packaging/my2.patch", "packaging/my3.patch", } self._check_repo_state(repo, "pack", ["pack", "orig"], files) eq_(len(repo.get_commits()), 2) # Check packaging dir eq_(len(repo.get_commits(paths="packaging")), 1) # Check tags tags = repo.get_tags() eq_(set(tags), set(["orig/2.0", "ver_2.0-rel_0"])) # Check git committer/author info = repo.get_commit_info("pack") eq_(info["author"].name, "Markus Lehtonen") eq_(info["author"].email, "*****@*****.**") eq_(info["author"].name, info["committer"].name) eq_(info["author"].email, info["committer"].email)
def test_multiple_versions(self): """Test importing of multiple versions""" srpms = [ os.path.join(DATA_DIR, 'gbp-test-1.0-1.src.rpm'), os.path.join(DATA_DIR, 'gbp-test-1.0-1.other.src.rpm'), os.path.join(DATA_DIR, 'gbp-test-1.1-1.src.rpm') ] eq_(mock_import(['--no-pristine-tar', srpms[0]]), 0) repo = GitRepository('gbp-test') self._check_repo_state(repo, 'master', ['master', 'upstream']) eq_(len(repo.get_commits()), 2) # Try to import same version again eq_(mock_import([srpms[1]]), 0) eq_(len(repo.get_commits()), 2) eq_(len(repo.get_commits(until='upstream')), 1) eq_(mock_import(['--no-pristine-tar', '--allow-same-version', srpms[1]]), 0) # Added new version of packaging eq_(len(repo.get_commits()), 3) eq_(len(repo.get_commits(until='upstream')), 1) # Import new version eq_(mock_import(['--no-pristine-tar', srpms[2]]), 0) files = {'Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt', 'gbp-test.spec', 'my.patch', 'my2.patch', 'my3.patch'} self._check_repo_state(repo, 'master', ['master', 'upstream'], files) eq_(len(repo.get_commits()), 5) eq_(len(repo.get_commits(until='upstream')), 2) # Check number of tags eq_(len(repo.get_tags('upstream/*')), 2) eq_(len(repo.get_tags('packaging/*')), 3)
def test_multiple_versions(self): """Test importing of multiple versions""" srpms = [ os.path.join(DATA_DIR, 'gbp-test-1.0-1.src.rpm'), os.path.join(DATA_DIR, 'gbp-test-1.0-1.other.src.rpm'), os.path.join(DATA_DIR, 'gbp-test-1.1-1.src.rpm') ] eq_(mock_import(['--no-pristine-tar', srpms[0]]), 0) repo = GitRepository('gbp-test') self._check_repo_state(repo, 'master', ['master', 'upstream']) eq_(len(repo.get_commits()), 4) # Try to import same version again eq_(mock_import([srpms[1]]), 0) eq_(len(repo.get_commits()), 4) eq_(len(repo.get_commits(until='upstream')), 1) eq_(mock_import(['--allow-same-version', srpms[1]]), 0) # Added new versio packaging plus one patch eq_(len(repo.get_commits()), 7) eq_(len(repo.get_commits(until='upstream')), 1) # Import new version eq_(mock_import([srpms[2]]), 0) files = set([ 'Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt', 'gbp-test.spec', 'my.patch', 'mydir/myfile.txt' ]) self._check_repo_state(repo, 'master', ['master', 'upstream'], files) eq_(len(repo.get_commits()), 11) eq_(len(repo.get_commits(until='upstream')), 2) # Check number of tags eq_(len(repo.get_tags('upstream/*')), 2) eq_(len(repo.get_tags('vendor/*')), 3)
def test_import_no_orig_src(self): """Test importing of (native) srpm without orig tarball""" srpm = os.path.join(DATA_DIR, 'gbp-test-native2-2.0-0.src.rpm') eq_(mock_import([srpm]), 0) # Check repository state repo = GitRepository('gbp-test-native2') self._check_repo_state(repo, 'master', ['master']) # Only one commit: packaging files eq_(len(repo.get_commits()), 1)
def test_basic_import_pristine_tar(self): """Test importing of non-native src.rpm, with pristine-tar""" srpm = os.path.join(DATA_DIR, "gbp-test-1.0-1.src.rpm") eq_(mock_import(["--pristine-tar", srpm]), 0) # Check repository state repo = GitRepository("gbp-test") self._check_repo_state(repo, "master", ["master", "upstream", "pristine-tar"]) # Two commits: upstream and packaging files eq_(len(repo.get_commits()), 2)
def test_basic_native_import(self): """Test importing of native src.rpm""" srpm = os.path.join(DATA_DIR, "gbp-test-native-1.0-1.src.rpm") eq_(mock_import(["--native", srpm]), 0) # Check repository state files = {".gbp.conf", "Makefile", "README", "dummy.sh", "packaging/gbp-test-native.spec"} repo = GitRepository("gbp-test-native") self._check_repo_state(repo, "master", ["master"], files) # Only one commit: the imported source tarball eq_(len(repo.get_commits()), 1)
def test_basic_import_pristine_tar(self): """Test importing of non-native src.rpm, with pristine-tar""" srpm = os.path.join(DATA_DIR, 'gbp-test-1.0-1.src.rpm') eq_(mock_import(['--pristine-tar', srpm]), 0) # Check repository state repo = GitRepository('gbp-test') self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar']) # Two commits: upstream and packaging files eq_(len(repo.get_commits()), 2)
def test_basic_import(self): """Test importing of non-native src.rpm""" srpm = os.path.join(DATA_DIR, 'gbp-test-1.0-1.src.rpm') eq_(mock_import(['--no-pristine-tar', srpm]), 0) # Check repository state repo = GitRepository('gbp-test') files = {'Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt', 'gbp-test.spec', 'my.patch', 'my2.patch', 'my3.patch'} self._check_repo_state(repo, 'master', ['master', 'upstream'], files) # Two commits: upstream and packaging files eq_(len(repo.get_commits()), 2)
def test_basic_native_import(self): """Test importing of native src.rpm""" srpm = os.path.join(DATA_DIR, 'gbp-test-native-1.0-1.src.rpm') eq_(mock_import(['--native', srpm]), 0) # Check repository state files = {'.gbp.conf', 'Makefile', 'README', 'dummy.sh', 'packaging/gbp-test-native.spec'} repo = GitRepository('gbp-test-native') self._check_repo_state(repo, 'master', ['master'], files) # Only one commit: the imported source tarball eq_(len(repo.get_commits()), 1)
def test_basic_import_orphan(self): """ Test importing of non-native src.rpm to separate packaging and development branches """ srpm = os.path.join(DATA_DIR, "gbp-test2-2.0-0.src.rpm") eq_(mock_import(["--no-pristine-tar", "--orphan-packaging", srpm]), 0) # Check repository state repo = GitRepository("gbp-test2") files = {"bar.tar.gz", "foo.txt", "gbp-test2.spec", "gbp-test2-alt.spec", "my.patch", "my2.patch", "my3.patch"} self._check_repo_state(repo, "master", ["master", "upstream"], files) # Only one commit: the packaging files eq_(len(repo.get_commits()), 1)
def test_basic_import2(self): """Import package with multiple spec files and full url patch""" srpm = os.path.join(DATA_DIR, 'gbp-test2-2.0-0.src.rpm') eq_(mock_import(['--no-pristine-tar', srpm]), 0) # Check repository state repo = GitRepository('gbp-test2') files = {'Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt', 'gbp-test2.spec', 'gbp-test2-alt.spec', 'my.patch', 'my2.patch', 'my3.patch'} self._check_repo_state(repo, 'master', ['master', 'upstream'], files) # Two commits: upstream and packaging files eq_(len(repo.get_commits()), 2)
def test_basic_import_orphan(self): """ Test importing of non-native src.rpm to separate packaging and development branches """ srpm = os.path.join(DATA_DIR, 'gbp-test2-2.0-0.src.rpm') eq_(mock_import(['--no-pristine-tar', '--orphan-packaging', srpm]), 0) # Check repository state repo = GitRepository('gbp-test2') files = {'bar.tar.gz', 'foo.txt', 'gbp-test2.spec', 'gbp-test2-alt.spec', 'my.patch', 'my2.patch', 'my3.patch'} self._check_repo_state(repo, 'master', ['master', 'upstream'], files) # Only one commit: the packaging files eq_(len(repo.get_commits()), 1)
def test_basic_import(self): """Test importing of non-native src.rpm""" srpm = os.path.join(DATA_DIR, 'gbp-test-1.0-1.src.rpm') eq_(mock_import(['--no-pristine-tar', srpm]), 0) # Check repository state repo = GitRepository('gbp-test') files = set([ 'Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt', 'gbp-test.spec', 'my.patch', 'mydir/myfile.txt' ]) self._check_repo_state(repo, 'master', ['master', 'upstream'], files) # Four commits: upstream, packaging files, one patch and the removal # of imported patches eq_(len(repo.get_commits()), 4)
def test_import_compressed_patches(self): """Test importing of non-native src.rpm with compressed patches""" srpm = os.path.join(DATA_DIR, 'gbp-test-1.1-2.src.rpm') eq_(mock_import([srpm]), 0) # Check repository state repo = GitRepository('gbp-test') files = set([ 'Makefile', 'README', 'AUTHORS', 'NEWS', 'bar.tar.gz', 'dummy.sh', 'foo.txt', 'gbp-test.spec', 'my.patch', 'mydir/myfile.txt' ]) self._check_repo_state(repo, 'master', ['master', 'upstream'], files) # Four commits: upstream, packaging files, three patches and the removal # of imported patches eq_(len(repo.get_commits()), 6)
def test_basic_import(self): """Test importing of non-native src.rpm""" srpm = os.path.join(DATA_DIR, "gbp-test-1.0-1.src.rpm") eq_(mock_import(["--no-pristine-tar", srpm]), 0) # Check repository state repo = GitRepository("gbp-test") files = { "Makefile", "README", "bar.tar.gz", "dummy.sh", "foo.txt", "gbp-test.spec", "my.patch", "my2.patch", "my3.patch", } self._check_repo_state(repo, "master", ["master", "upstream"], files) # Two commits: upstream and packaging files eq_(len(repo.get_commits()), 2)
def test_basic_import2(self): """Import package with multiple spec files and full url patch""" srpm = os.path.join(DATA_DIR, "gbp-test2-2.0-0.src.rpm") eq_(mock_import(["--no-pristine-tar", srpm]), 0) # Check repository state repo = GitRepository("gbp-test2") files = { "Makefile", "README", "bar.tar.gz", "dummy.sh", "foo.txt", "gbp-test2.spec", "gbp-test2-alt.spec", "my.patch", "my2.patch", "my3.patch", } self._check_repo_state(repo, "master", ["master", "upstream"], files) # Two commits: upstream and packaging files eq_(len(repo.get_commits()), 2)
def test_multiple_versions(self): """Test importing of multiple versions""" srpms = [ os.path.join(DATA_DIR, "gbp-test-1.0-1.src.rpm"), os.path.join(DATA_DIR, "gbp-test-1.0-1.other.src.rpm"), os.path.join(DATA_DIR, "gbp-test-1.1-1.src.rpm"), ] eq_(mock_import(["--no-pristine-tar", srpms[0]]), 0) repo = GitRepository("gbp-test") self._check_repo_state(repo, "master", ["master", "upstream"]) eq_(len(repo.get_commits()), 2) # Try to import same version again eq_(mock_import([srpms[1]]), 0) eq_(len(repo.get_commits()), 2) eq_(len(repo.get_commits(until="upstream")), 1) eq_(mock_import(["--no-pristine-tar", "--allow-same-version", srpms[1]]), 0) # Added new version of packaging eq_(len(repo.get_commits()), 3) eq_(len(repo.get_commits(until="upstream")), 1) # Import new version eq_(mock_import(["--no-pristine-tar", srpms[2]]), 0) files = { "Makefile", "README", "bar.tar.gz", "dummy.sh", "foo.txt", "gbp-test.spec", "my.patch", "my2.patch", "my3.patch", } self._check_repo_state(repo, "master", ["master", "upstream"], files) eq_(len(repo.get_commits()), 5) eq_(len(repo.get_commits(until="upstream")), 2) # Check number of tags eq_(len(repo.get_tags("upstream/*")), 2) eq_(len(repo.get_tags("packaging/*")), 3)