aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2019-10-07 11:23:13 +0200
committerGuido Günther <agx@sigxcpu.org>2019-10-07 13:49:11 +0200
commit11f9f31d52bf894e41728b25c0994f88ead3fedd (patch)
treee930c58089991a6640ec0a501d56900b6e2a7966
parentfb26fd9229f8a836e8ddef643e6e9c4c128dd2af (diff)
export-orig: Check 'origin/pristine-tar' as well for compression type
Closes: #941894
-rwxr-xr-xgbp/scripts/export_orig.py15
-rw-r--r--tests/05_test_detection.py3
-rw-r--r--tests/component/deb/test_export_orig.py18
3 files changed, 31 insertions, 5 deletions
diff --git a/gbp/scripts/export_orig.py b/gbp/scripts/export_orig.py
index 6a48502..c288501 100755
--- a/gbp/scripts/export_orig.py
+++ b/gbp/scripts/export_orig.py
@@ -235,14 +235,20 @@ def guess_comp_type(comp_type, source, repo, tarball_dir):
comp_type = 'auto'
if comp_type == 'auto':
- if repo and repo.has_pristine_tar_branch():
+ branch = None
+ if repo.has_branch('pristine-tar'):
+ branch = 'pristine-tar'
+ elif repo.has_branch('origin/pristine-tar', remote=True):
+ branch = 'origin/pristine-tar'
+
+ if branch:
regex = r'pristine-tar .* %s_%s\.orig.tar\.' % (source.name, source.upstream_version)
- commits = repo.grep_log(regex, repo.pristine_tar_branch, merges=False)
+ commits = repo.grep_log(regex, branch, merges=False)
if commits:
commit = commits[-1]
gbp.log.debug("Found pristine-tar commit at '%s'" % commit)
else:
- commit = repo.pristine_tar_branch
+ commit = branch
tarball = repo.get_commit_info(commit)['subject']
(base_name, archive_fmt, comp_type) = Archive.parse_filename(tarball)
gbp.log.debug("Determined compression type '%s'" % comp_type)
@@ -250,8 +256,7 @@ def guess_comp_type(comp_type, source, repo, tarball_dir):
comp_type = 'gzip'
gbp.log.warn("Unknown compression type of %s, assuming %s" % (tarball, comp_type))
else:
- if not tarball_dir:
- tarball_dir = '..'
+ tarball_dir = tarball_dir or '..'
detected = None
for comp in Compressor.Opts.keys():
if du.DebianPkgPolicy.has_orig(source.upstream_tarball_name(comp), tarball_dir):
diff --git a/tests/05_test_detection.py b/tests/05_test_detection.py
index 5e903db..d632233 100644
--- a/tests/05_test_detection.py
+++ b/tests/05_test_detection.py
@@ -21,6 +21,9 @@ class MockGitRepository:
def has_pristine_tar_branch(self):
return self.with_branch
+ def has_branch(self, branch, remote=False):
+ return branch == 'pristine-tar' and self.with_branch
+
def pristine_tar_branch(self):
'pristine-tar'
diff --git a/tests/component/deb/test_export_orig.py b/tests/component/deb/test_export_orig.py
index b2a8e8b..c01562d 100644
--- a/tests/component/deb/test_export_orig.py
+++ b/tests/component/deb/test_export_orig.py
@@ -21,9 +21,11 @@ import os
from tests.component import (ComponentTestBase,
ComponentTestGitRepository)
from tests.component.deb import DEB_TEST_DATA_DIR
+from tests.component.deb.fixtures import RepoFixtures
from nose.tools import ok_, assert_false, assert_true
+from gbp.scripts.clone import main as clone
from gbp.scripts.import_dsc import main as import_dsc
from gbp.scripts.export_orig import main as export_orig
@@ -136,3 +138,19 @@ class TestExportOrig(ComponentTestBase):
for t in tarballs:
self.assertFalse(os.path.exists(os.path.join('..', t)), "Tarball %s found" % t)
self.assertTrue(os.path.exists(os.path.join(DEB_TEST_DATA_DIR, 'foo-2.8', t)), "Tarball %s not found" % t)
+
+ @RepoFixtures.quilt30(opts=['--pristine-tar'])
+ def test_pristine_tar_commit_on_origin(self, repo):
+ """Test that we can create tarball from 'origin/pristine-tar'"""
+
+ assert_true(repo.has_branch('pristine-tar'),
+ "Pristine-tar branch must exist in origin")
+ dest = os.path.join(self._tmpdir, 'cloned_repo')
+ clone(['arg0', repo.path, dest])
+ cloned = ComponentTestGitRepository(dest)
+
+ os.chdir(cloned.path)
+ assert_false(cloned.has_branch('pristine-tar'),
+ "Pristine-tar branch must not exist in clone")
+ ret = export_orig(['arg0', '--pristine-tar'])
+ ok_(ret == 0, "Exporting tarballs must not fail")