summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLoïc Minier <lool@debian.org>2011-04-08 03:38:12 +0200
committerGuido Günther <agx@sigxcpu.org>2011-04-09 22:42:24 +0200
commitabf76d0ad980f405f458d54051d0f75a847d25a7 (patch)
treeb6bdee84f8b74e216a2d929f7cf23091c6469a15
parent8189cc9e01ed42f67b20d59a9f18247779a86ed4 (diff)
Update guess_comp_type to take a cp as param
Git-Dch: Ignore
-rwxr-xr-xgit-buildpackage7
-rw-r--r--tests/05_test_detection.py12
2 files changed, 10 insertions, 9 deletions
diff --git a/git-buildpackage b/git-buildpackage
index 6223213a..aa7d1ef5 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -263,9 +263,12 @@ def extract_orig(orig_tarball, dest_dir):
os.rmdir(tar_topdir)
-def guess_comp_type(repo, comp_type, srcpkg, upstream_version):
+def guess_comp_type(repo, comp_type, cp):
"""Guess compression type"""
+ srcpkg = cp['Source']
+ upstream_version = cp['Upstream-Version']
+
if comp_type != 'auto':
try:
dummy = du.compressor_opts[comp_type]
@@ -451,7 +454,7 @@ def main(argv):
# Get/build the orig.tar.gz if necessary:
if not du.is_native(cp):
- options.comp_type = guess_comp_type(repo, options.comp_type, cp['Source'], major)
+ options.comp_type = guess_comp_type(repo, options.comp_type, cp)
orig_file = du.orig_file(cp, options.comp_type)
# look in tarball_dir first, if found force a symlink to it
diff --git a/tests/05_test_detection.py b/tests/05_test_detection.py
index 1454e4da..9c7abfcd 100644
--- a/tests/05_test_detection.py
+++ b/tests/05_test_detection.py
@@ -23,28 +23,26 @@ class MockGitRepository:
class TestDetection(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp()
+ self.cp = {'Source': 'source', 'Upstream-Version': '1.2'}
def tearDown(self):
shutil.rmtree(self.tmpdir)
def test_guess_comp_type_no_pristine_tar(self):
repo = MockGitRepository(with_branch=False)
- guessed = git_buildpackage.guess_comp_type(repo, 'auto', None, None)
+ guessed = git_buildpackage.guess_comp_type(repo, 'auto', self.cp)
self.assertEqual('gzip', guessed)
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)
- guessed = git_buildpackage.guess_comp_type(
- repo, 'auto', 'source', '1.2')
+ guessed = git_buildpackage.guess_comp_type(repo, 'auto', self.cp)
self.assertEqual("bzip2", guessed)
def test_has_orig_false(self):
- cp = {'Source': 'source', 'Upstream-Version': '1.2'}
- self.assertFalse(has_orig(cp, 'gzip', self.tmpdir))
+ self.assertFalse(has_orig(self.cp, 'gzip', self.tmpdir))
def test_has_orig_true(self):
- cp = {'Source': 'source', 'Upstream-Version': '1.2'}
open(os.path.join(self.tmpdir, 'source_1.2.orig.tar.gz'), "w").close()
- self.assertTrue(has_orig(cp, 'gzip', self.tmpdir))
+ self.assertTrue(has_orig(self.cp, 'gzip', self.tmpdir))