Commit 6abb9e8b authored by Guido Günther's avatar Guido Günther

buildpackage: don't require debian/ prefix for --git-dist=DEP14 to work

parent 65a043db
......@@ -199,6 +199,7 @@ def get_pbuilder_dist(options, repo, native=False):
Determin the dist to build for with pbuilder/cowbuilder
dist = None
if options.pbuilder_dist == 'DEP14':
vendor = du.get_vendor().lower()
branch = repo.branch
......@@ -206,15 +207,20 @@ def get_pbuilder_dist(options, repo, native=False):
raise GbpError("Failed to setup DIST for %s. "
"Can't determine current branch." % options.builder)
parts = branch.rsplit('/')
if len(parts) == 2:
if len(parts) == 2: # e.g. debian/stretch
suite = parts[1]
if vendor == parts[0]:
dist = '' if suite in ['sid', 'master'] else suite
dist = '%s_%s' % (parts[0], suite)
elif len(parts) == 1 and native and branch in ['master', 'sid']:
dist = ''
# Branches in Debian often omit the debian/ prefix
elif len(parts) == 1 and vendor.lower() == "debian":
if branch in ['master', 'sid']:
dist = ''
elif branch in du.Releases:
dist = branch
if dist is None:
raise GbpError("DEP14 DIST: Current branch '%s' does not match vendor/suite" % branch)
dist = options.pbuilder_dist
......@@ -69,13 +69,20 @@ class TestGbpBuildpackageDep14(DebianGitTestRepo):
self.assertEqual(get_pbuilder_dist(self.options, self.repo), 'downstream_mies-lts')
@patch('gbp.deb.get_vendor', return_value='Debian')
def test_get_pbuilder_dist_dep14_no_vendor(self, patch):
def test_get_pbuilder_dist_dep14_no_vendor_sid(self, patch):
branch = 'sid'
with self.assertRaisesRegexp(GbpError,
"DEP14 DIST: Current branch 'sid' does not match vendor/suite"):
get_pbuilder_dist(self.options, self.repo)
self.assertEqual(get_pbuilder_dist(self.options, self.repo), '')
@patch('gbp.deb.get_vendor', return_value='Debian')
def test_get_pbuilder_dist_dep14_no_vendor(self, patch):
branch = 'wheezy'
self.assertEqual(get_pbuilder_dist(self.options, self.repo), 'wheezy')
def test_get_pbuilder_dist_dep14_too_many_slashes(self):
branch = 'too/many/slashes'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment