From: Guido Günther Date: Sun, 23 Feb 2014 15:59:44 +0000 (+0100) Subject: import_dsc: Create missing debian branch with --create-missing-branches X-Git-Tag: debian/0.6.10~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d533e0f6f418a1cc002786ab7d96481ecc3bd9b4;p=tools%2Fgit-buildpackage.git import_dsc: Create missing debian branch with --create-missing-branches Closes: #739888 --- diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py index d60e0d1..630422b 100644 --- a/gbp/scripts/import_dsc.py +++ b/gbp/scripts/import_dsc.py @@ -377,7 +377,8 @@ def main(argv): repo.create_branch(options.upstream_branch, commit) if options.pristine_tar: repo.pristine_tar.commit(src.tgz, options.upstream_branch) - if is_empty and not repo.has_branch(options.debian_branch): + if (not repo.has_branch(options.debian_branch) + and (is_empty or options.create_missing_branches)): repo.create_branch(options.debian_branch, commit) if not src.native: if src.diff or src.deb_tgz: diff --git a/tests/component/deb/data b/tests/component/deb/data index fce347e..a06e148 160000 --- a/tests/component/deb/data +++ b/tests/component/deb/data @@ -1 +1 @@ -Subproject commit fce347ecd0739fe29776a761775a92456a362af9 +Subproject commit a06e148c09b6f9c9057ecdcabcbeed7d71ba0a18 diff --git a/tests/component/deb/test_import_dsc.py b/tests/component/deb/test_import_dsc.py index bccdb07..da16615 100644 --- a/tests/component/deb/test_import_dsc.py +++ b/tests/component/deb/test_import_dsc.py @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2013 Guido Günther +# (C) 2013,2014 Guido Günther # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,10 +22,12 @@ from tests.component import (ComponentTestBase, ComponentTestGitRepository) from tests.component.deb import DEB_TEST_DATA_DIR +from nose.tools import ok_ + from gbp.scripts.import_dsc import main as import_dsc class TestImportDsc(ComponentTestBase): - """Test importing of src.rpm files""" + """Test importing of debian source packages""" def test_debian_import(self): """Test that importing of debian native packages works""" @@ -50,3 +52,31 @@ class TestImportDsc(ComponentTestBase): assert import_dsc(['arg0', dsc]) == 0 self._check_repo_state(repo, 'master', ['master']) assert len(repo.get_commits()) == 3 + + def test_create_branches(self): + """Test if creating missing branches works""" + def _dsc(version): + return os.path.join(DEB_TEST_DATA_DIR, + 'dsc-3.0', + 'hello-debhelper_%s.dsc' % version) + + dsc = _dsc('2.6-2') + assert import_dsc(['arg0', + '--pristine-tar', + '--debian-branch=master', + '--upstream-branch=upstream', + dsc]) == 0 + repo = ComponentTestGitRepository('hello-debhelper') + os.chdir('hello-debhelper') + assert len(repo.get_commits()) == 2 + self._check_repo_state(repo, 'master', ['master', 'pristine-tar', 'upstream']) + dsc = _dsc('2.8-1') + assert import_dsc(['arg0', + '--pristine-tar', + '--debian-branch=foo', + '--upstream-branch=bar', + '--create-missing-branches', + dsc]) == 0 + self._check_repo_state(repo, 'master', ['bar', 'foo', 'master', 'pristine-tar', 'upstream']) + commits, expected = len(repo.get_commits()), 2 + ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))