aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-10-23 21:18:18 +0200
committerGuido Günther <agx@sigxcpu.org>2017-10-23 21:25:48 +0200
commit01da1e61b003aa7cb576fbe5755a665a12c3f2ba (patch)
tree264ffde1933902d5463f9e13109e3b0fe2c31e7f /tests
parentf18d6b4c2ce098bc12bf4e7fc29dfec7dc16d581 (diff)
import-dsc: make sure we don't create 'master' if not needed
This way we only get the debian- and upstream-branch in empty repos and not a pointless 'master' if debian-branch is not set to master. It also makes sure we don't need --create-missing-branches on empty repos where it is pointless. Closes: #750962
Diffstat (limited to 'tests')
-rw-r--r--tests/component/deb/test_import_dsc.py48
1 files changed, 47 insertions, 1 deletions
diff --git a/tests/component/deb/test_import_dsc.py b/tests/component/deb/test_import_dsc.py
index 1d824124..9a91f14f 100644
--- a/tests/component/deb/test_import_dsc.py
+++ b/tests/component/deb/test_import_dsc.py
@@ -29,6 +29,7 @@ from nose.tools import ok_, eq_
from gbp.scripts.import_dsc import main as import_dsc
from gbp.deb.pristinetar import DebianPristineTar
from gbp.deb.dscfile import DscFile
+from gbp.git.repository import GitRepository
class TestImportDsc(ComponentTestBase):
@@ -53,7 +54,8 @@ class TestImportDsc(ComponentTestBase):
# the second
ok_(b"gbp: Import Debian changes" in reflog[0])
else:
- assert ok_(len(reflog) in [2, 3])
+ ok_(len(reflog) > 3, "Reflog %s has too many lines" % reflog)
+ ok_(len(reflog) < 2, "Reflog %s has too few lines" % reflog)
def test_import_debian_native(self):
"""Test that importing of debian native packages works"""
@@ -303,3 +305,47 @@ class TestImportDsc(ComponentTestBase):
got = repo.get_config("user.name")
want = os.environ['DEBFULLNAME']
ok_(got == want, "unexpected git config user.name: got %s, want %s" % (got, want))
+
+ def test_debian_branch_not_master(self):
+ """Make sure we only have debian-branch and upstream-branch after an initial import"""
+ dsc = self._dsc30('2.6-2')
+ assert import_dsc(['arg0',
+ '--verbose',
+ '--no-pristine-tar',
+ '--debian-branch=pk4',
+ '--upstream-branch=upstream',
+ dsc]) == 0
+ repo = ComponentTestGitRepository('hello-debhelper')
+ self._check_repo_state(repo, 'pk4', ['pk4', 'upstream'])
+ commits, expected = len(repo.get_commits()), 2
+ ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))
+
+ def test_empty_repo(self):
+ """Make sure we can import into an empty repository"""
+ dsc = self._dsc30('2.6-2')
+ repo = GitRepository.create("hello-debhelper")
+ self._check_repo_state(repo, None, [])
+ os.chdir('hello-debhelper')
+ assert import_dsc(['arg0',
+ '--verbose',
+ '--no-pristine-tar',
+ '--debian-branch=pk4',
+ '--upstream-branch=upstream',
+ dsc]) == 0
+ self._check_repo_state(repo, 'pk4', ['pk4', 'upstream'])
+ commits, expected = len(repo.get_commits()), 2
+ ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))
+
+ def test_upstream_branch_is_master(self):
+ """Make sure we can import when upstream-branch == master (#750962)"""
+ dsc = self._dsc30('2.6-2')
+ assert import_dsc(['arg0',
+ '--verbose',
+ '--no-pristine-tar',
+ '--debian-branch=debian',
+ '--upstream-branch=master',
+ dsc]) == 0
+ repo = ComponentTestGitRepository('hello-debhelper')
+ self._check_repo_state(repo, 'debian', ['debian', 'master'])
+ commits, expected = len(repo.get_commits()), 2
+ ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))