本文整理汇总了Python中gbp.git.GitRepository类的典型用法代码示例。如果您正苦于以下问题:Python GitRepository类的具体用法?Python GitRepository怎么用?Python GitRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GitRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_multiple_versions
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)
示例2: test_misc_options
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, '[email protected]')
eq_(info['author'].name, info['committer'].name)
eq_(info['author'].email, info['committer'].email)
示例3: test_basic_import_pristine_tar
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)
示例4: test_invalid_config_file
def test_invalid_config_file(self):
"""Test invalid config file"""
# Create dummy invalid config file and run pq-rpm
GitRepository.create('.')
with open('.gbp.conf', 'w') as conffd:
conffd.write('foobar\n')
eq_(mock_pq(['foo']), 1)
self._check_log(0, 'gbp:error: Invalid config file: File contains no '
'section headers.')
示例5: test_import_no_orig_src
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)
示例6: test_basic_native_import
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)
示例7: test_basic_import_pristine_tar
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)
示例8: test_basic_import
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)
示例9: test_basic_native_import
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)
示例10: test_basic_import_orphan
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)
示例11: test_basic_import2
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)
示例12: test_basic_import_orphan
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)
示例13: test_import_to_existing
def test_import_to_existing(self):
"""Test importing to an existing repo"""
srpm = os.path.join(DATA_DIR, "gbp-test-1.0-1.src.rpm")
# Create new repo
repo = GitRepository.create("myrepo")
os.chdir("myrepo")
shutil.copy2(".git/HEAD", "foobar")
repo.add_files(".")
repo.commit_all("First commit")
# Test importing to non-clean repo
shutil.copy2(".git/HEAD", "foobaz")
eq_(mock_import(["--create-missing", srpm]), 1)
self._check_log(0, "gbp:error: Repository has uncommitted changes")
self._clear_log()
os.unlink("foobaz")
# The first import should fail because upstream branch is missing
eq_(mock_import([srpm]), 1)
self._check_log(-1, "Also check the --create-missing-branches")
eq_(mock_import(["--no-pristine-tar", "--create-missing", srpm]), 0)
self._check_repo_state(repo, "master", ["master", "upstream"])
# Four commits: our initial, upstream and packaging files
eq_(len(repo.get_commits()), 3)
# The import should fail because missing packaging-branch
srpm = os.path.join(DATA_DIR, "gbp-test-1.1-1.src.rpm")
eq_(mock_import(["--packaging-branch=foo", srpm]), 1)
self._check_log(-1, "Also check the --create-missing-branches")
示例14: test_invalid_args
def test_invalid_args(self):
"""See that pq-rpm fails gracefully when called with invalid args"""
GitRepository.create('.')
# Test empty args
eq_(mock_pq([]), 1)
self._check_log(0, 'gbp:error: No action given.')
self._clear_log()
# Test invalid command
eq_(mock_pq(['mycommand']), 1)
self._check_log(0, "gbp:error: Unknown action 'mycommand'")
self._clear_log()
# Test invalid cmdline options
with assert_raises(SystemExit):
mock_pq(['--invalid-arg=123'])
示例15: setup_class
def setup_class(cls):
"""Initializations only made once per test run"""
super(RpmRepoTestBase, cls).setup_class()
cls.manifest = RepoManifest(os.path.join(RPM_TEST_DATA_DIR,
'test-repo-manifest.xml'))
cls.orig_repos = {}
for prj, brs in cls.manifest.projects_iter():
repo = GitRepository.create(os.path.join(cls._tmproot,
'%s.repo' % prj))
try:
repo.add_remote_repo('origin', RPM_TEST_DATA_DIR, fetch=True)
except GitRepositoryError:
# Workaround for older git working on submodules initialized
# with newer git
gitfile = os.path.join(RPM_TEST_DATA_DIR, '.git')
if os.path.isfile(gitfile):
with open(gitfile) as fobj:
link = fobj.readline().replace('gitdir:', '').strip()
link_dir = os.path.join(RPM_TEST_DATA_DIR, link)
repo.remove_remote_repo('origin')
repo.add_remote_repo('origin', link_dir, fetch=True)
else:
raise
# Fetch all remote refs of the orig repo, too
repo.fetch('origin', tags=True,
refspec='refs/remotes/*:refs/upstream/*')
for branch, rev in brs.iteritems():
repo.create_branch(branch, rev)
repo.force_head('master', hard=True)
cls.orig_repos[prj] = repo