From 9a2c5e669ef6ed23a96bbd7cc9028cacb4da37ad Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Thu, 16 Nov 2017 08:38:02 +0100 Subject: import_orig: drop debian/ again in --merge-mode=replace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Another fallout of the Python3 conversion Closes: #881750 Thanks: Víctor Cuadrado Juan for providing a nice reproducer --- gbp/scripts/import_orig.py | 2 +- tests/24_test_gbp_import_orig.py | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index b67424e5..7c911f6a 100644 --- a/gbp/scripts/import_orig.py +++ b/gbp/scripts/import_orig.py @@ -365,7 +365,7 @@ def debian_branch_merge_by_replace(repo, tag, version, options): gbp.log.info("Replacing upstream source on '%s'" % options.debian_branch) tree = [x for x in repo.list_tree("%s^{tree}" % tag) - if x[-1] != 'debian'] + if x[-1] != b'debian'] msg = "Update upstream source from tag '%s'" % (tag) # Get the current debian/ tree on the debian branch diff --git a/tests/24_test_gbp_import_orig.py b/tests/24_test_gbp_import_orig.py index c7619c35..419ac403 100644 --- a/tests/24_test_gbp_import_orig.py +++ b/tests/24_test_gbp_import_orig.py @@ -6,7 +6,10 @@ import unittest from collections import namedtuple -from gbp.scripts.import_orig import (ImportOrigDebianGitRepository, GbpError, is_30_quilt) +from gbp.scripts.import_orig import (debian_branch_merge_by_replace, + GbpError, + ImportOrigDebianGitRepository, + is_30_quilt) from gbp.scripts.common.import_orig import download_orig from . testutils import DebianGitTestRepo @@ -105,3 +108,27 @@ class TestIs30Quilt(DebianGitTestRepo): def test_30_quilt_empty_repo(self): options = self.Options(debian_branch='master') self.assertFalse(is_30_quilt(self.repo, options)) + + +class TestMergeModeReplace(DebianGitTestRepo): + debian_branch = 'master' + + def setUp(self): + DebianGitTestRepo.setUp(self) + os.chdir(self.repo.path) + + def testDebianDir(self): + """Test that dropping upstream's debian/ workd (#881750)""" + self.add_file("debian/control") + self.repo.create_branch("upstream") + self.repo.set_branch("upstream") + self.add_file("upstream_file") + self.add_file("debian/changelog") + self.repo.set_branch("master") + self.repo.create_tag('upstream/1.0', "Upstream 1.0", "upstream") + debian_branch_merge_by_replace(self.repo, "upstream/1.0", "1.0", self) + self.assertTrue(os.path.exists("debian/control")) + # Upstream files must end up on debian branch… + self.assertTrue(os.path.exists("upstream_file")) + # … but upsream's debian dir must not + self.assertFalse(os.path.exists("debian/changelog")) -- cgit v1.2.3