summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLoïc Minier <lool@debian.org>2011-04-08 03:54:07 +0200
committerGuido Günther <agx@sigxcpu.org>2011-04-09 22:42:36 +0200
commit85c5d8ea421805421e78d202c1105da8b7de90c4 (patch)
tree90ccafb39e2872fe0945defe4decba640565acc5
parent1919f2677e963a64cef2b62373f25d0cfab99e95 (diff)
Detect compression from orig tarball
-rwxr-xr-xgit-buildpackage13
-rw-r--r--tests/05_test_detection.py22
2 files changed, 33 insertions, 2 deletions
diff --git a/git-buildpackage b/git-buildpackage
index 11773ab0..c52cd017 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -278,7 +278,18 @@ def guess_comp_type(repo, comp_type, cp, tarball_dir):
if comp_type == 'auto':
if not repo.has_branch(PristineTar.branch):
- comp_type = 'gzip'
+ if not tarball_dir:
+ tarball_dir = '..'
+ detected = None
+ for comp in du.compressor_opts.keys():
+ if du.has_orig(cp, comp, tarball_dir):
+ if detected is not None:
+ raise GbpError, "Multiple orig tarballs found."
+ detected = comp
+ if detected is not None:
+ comp_type = detected
+ else:
+ comp_type = 'gzip'
else:
regex = 'pristine-tar .* %s_%s\.orig.tar\.' % (srcpkg, upstream_version)
commits = repo.grep_log(regex, PristineTar.branch)
diff --git a/tests/05_test_detection.py b/tests/05_test_detection.py
index 4c028ff0..72c93161 100644
--- a/tests/05_test_detection.py
+++ b/tests/05_test_detection.py
@@ -5,6 +5,7 @@ import unittest
import git_buildpackage
from gbp.deb import has_orig
+from gbp.errors import GbpError
class MockGitRepository:
def __init__(self, with_branch=False, subject=None):
@@ -28,12 +29,31 @@ class TestDetection(unittest.TestCase):
def tearDown(self):
shutil.rmtree(self.tmpdir)
- def test_guess_comp_type_no_pristine_tar(self):
+ def test_guess_comp_type_no_pristine_tar_no_orig(self):
repo = MockGitRepository(with_branch=False)
guessed = git_buildpackage.guess_comp_type(
repo, 'auto', self.cp, self.tmpdir)
self.assertEqual('gzip', guessed)
+ def test_guess_comp_type_no_pristine_tar_with_orig(self):
+ open(os.path.join(self.tmpdir, 'source_1.2.orig.tar.bz2'), "w").close()
+ repo = MockGitRepository(with_branch=False)
+ guessed = git_buildpackage.guess_comp_type(
+ repo, 'auto', self.cp, self.tmpdir)
+ self.assertEqual('bzip2', guessed)
+
+ def test_guess_comp_type_no_pristine_tar_with_multiple_origs(self):
+ open(os.path.join(self.tmpdir, 'source_1.2.orig.tar.gz'), "w").close()
+ open(os.path.join(self.tmpdir, 'source_1.2.orig.tar.xz'), "w").close()
+ repo = MockGitRepository(with_branch=False)
+ self.assertRaises(
+ GbpError,
+ git_buildpackage.guess_comp_type,
+ repo,
+ 'auto',
+ self.cp,
+ self.tmpdir)
+
def test_guess_comp_type_bzip2(self):
subject = 'pristine-tar data for source_1.2-3.orig.tar.bz2'
repo = MockGitRepository(with_branch=True, subject=subject)