return set(blobs)
@classmethod
- def _check_repo_state(cls, repo, current_branch, branches, files=None):
+ def _check_repo_state(cls, repo, current_branch, branches, files=None,
+ dirs=None):
"""Check that repository is clean and given branches exist"""
branch = repo.branch
eq_(branch, current_branch)
assert_msg = "Branches: expected %s, found %s" % (branches,
local_branches)
eq_(set(local_branches), set(branches), assert_msg)
- if files is not None:
+ if files is not None or dirs is not None:
# Get files of the working copy recursively
- local = set()
+ local_f = set()
+ local_d = set()
for dirpath, dirnames, filenames in os.walk(repo.path):
# Skip git dir(s)
if '.git' in dirnames:
dirnames.remove('.git')
for filename in filenames:
- local.add(os.path.relpath(os.path.join(dirpath, filename),
- repo.path))
+ local_f.add(os.path.relpath(os.path.join(dirpath, filename),
+ repo.path))
for dirname in dirnames:
- local.add(os.path.relpath(os.path.join(dirpath, dirname),
- repo.path) + '/')
- cls.check_files(files, local)
+ local_d.add(os.path.relpath(os.path.join(dirpath, dirname),
+ repo.path) + '/')
+ if files is not None:
+ cls.check_files(files, local_f)
+ if dirs is not None:
+ cls.check_files(dirs, local_d)
def _capture_log(self, capture=True):
""" Capture log"""
# Guessing from the original archive should succeed
eq_(mock_import(['--no-interactive', '--merge', orig],
stdin_data=''), 0)
- files = ['.gbp.conf', 'Makefile', 'README', 'dummy.sh', 'packaging/',
+ files = ['.gbp.conf', 'Makefile', 'README', 'dummy.sh',
'packaging/gbp-test-native.spec']
self._check_repo_state(repo, 'master', ['master', 'upstream'], files)
eq_(len(repo.get_commits(until='master')), 1)
# Check repository state
repo = GitRepository('gbp-test')
files = set(['Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt',
- 'gbp-test.spec', 'my.patch', 'mydir/', 'mydir/myfile.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
# Check repository state
repo = GitRepository('gbp-test2')
files = set(['Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt',
- 'gbp-test2.spec', 'gbp-test2-alt.spec', 'my.patch', 'mydir/',
- 'mydir/myfile.txt'])
+ 'gbp-test2.spec', 'gbp-test2-alt.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
eq_(mock_import(['--native', srpm]), 0)
# Check repository state
files = set(['.gbp.conf', 'Makefile', 'README', 'dummy.sh',
- 'packaging/', 'packaging/gbp-test-native.spec'])
+ '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
repo = GitRepository('gbp-test')
files = set(['Makefile', 'README', 'AUTHORS', 'NEWS', 'bar.tar.gz',
'dummy.sh', 'foo.txt', 'gbp-test.spec', 'my.patch',
- 'mydir/', 'mydir/myfile.txt'])
+ '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
# 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/', 'mydir/myfile.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 repository state
repo = GitRepository('gbp-test')
files = set(['Makefile', 'dummy.sh', 'bar.tar.gz', 'foo.txt',
- 'gbp-test.spec', 'my.patch', 'mydir/', 'mydir/myfile.txt'])
+ 'gbp-test.spec', 'my.patch', 'mydir/myfile.txt'])
self._check_repo_state(repo, 'master', ['master', 'upstream'], files)
def test_misc_options(self):
srpm]), 0)
# Check repository state
repo = GitRepository('gbp-test2')
- files = set(['Makefile', 'README', 'dummy.sh', 'packaging/',
- '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'])
+ 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
branches = repo.get_local_branches() + ['development/master']
# Test import
eq_(mock_pq(['import']), 0)
- files = ['AUTHORS', 'dummy.sh', 'Makefile', 'NEWS', 'README', 'mydir/',
+ files = ['AUTHORS', 'dummy.sh', 'Makefile', 'NEWS', 'README',
'mydir/myfile.txt', '.gbp.conf']
branches.append('development/master')
self._check_repo_state(repo, 'development/master', branches, files)
repo.set_branch('master-orphan')
# Import
eq_(mock_pq(['import']), 0)
- files = ['dummy.sh', 'Makefile', 'README', 'mydir/',
- 'mydir/myfile.txt', '.gbp.conf']
+ files = ['dummy.sh', 'Makefile', 'README', 'mydir/myfile.txt',
+ '.gbp.conf']
self._check_repo_state(repo, 'development/master-orphan', branches,
files)
# Import
eq_(mock_pq(['import']), 0)
pq_files = ['AUTHORS', 'dummy.sh', 'Makefile', 'NEWS', 'README',
- 'mydir/', 'mydir/myfile.txt', '.gbp.conf']
+ 'mydir/myfile.txt', '.gbp.conf']
branches.append('development/master')
self._check_repo_state(repo, 'development/master', branches, pq_files)
tmp_patch.file.flush()
eq_(mock_pq(['apply', tmp_patch.name]), 0)
self._check_repo_state(repo, 'development/master', branches,
- upstr_files + ['mydir/', 'mydir/myfile.txt'])
+ upstr_files + ['mydir/myfile.txt'])
def test_convert(self):
"""Basic test for convert action"""
repo = self.init_test_repo('gbp-test2')
branches = repo.get_local_branches() + ['master-orphan']
- files = ['packaging/', 'packaging/bar.tar.gz', 'packaging/foo.txt',
+ files = ['packaging/bar.tar.gz', 'packaging/foo.txt',
'packaging/gbp-test2.spec', 'packaging/gbp-test2-alt.spec',
'packaging/my.patch', 'packaging/0001-My-addition.patch',
'.gbp.conf']
"""Test the --new-packaging-dir cmdline option"""
repo = self.init_test_repo('gbp-test2')
branches = repo.get_local_branches() + ['master-orphan']
- files = ['rpm/', 'rpm/bar.tar.gz', 'rpm/foo.txt',
- 'rpm/gbp-test2.spec', 'rpm/gbp-test2-alt.spec',
- 'rpm/my.patch', 'rpm/0001-My-addition.patch']
+ files = ['rpm/bar.tar.gz', 'rpm/foo.txt', 'rpm/gbp-test2.spec',
+ 'rpm/gbp-test2-alt.spec', 'rpm/my.patch',
+ 'rpm/0001-My-addition.patch']
# Drop already-existing master-orphan branch
repo.delete_branch('master-orphan')
# Try convert
"""Test the --retain-history cmdline option"""
repo = self.init_test_repo('gbp-test2')
branches = repo.get_local_branches() + ['master-orphan']
- files = ['packaging/', 'packaging/bar.tar.gz', 'packaging/foo.txt',
+ files = ['packaging/bar.tar.gz', 'packaging/foo.txt',
'packaging/gbp-test2.spec', 'packaging/gbp-test2-alt.spec',
'packaging/my.patch', 'packaging/0001-My-addition.patch',
'.gbp.conf']