deb: minor refactor of parameters of has_orig()
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 12 Jan 2012 13:24:19 +0000 (15:24 +0200)
committerGuido Günther <agx@sigxcpu.org>
Sun, 15 Jan 2012 18:55:40 +0000 (19:55 +0100)
gbp/deb/__init__.py [changed mode: 0755->0644]
gbp/scripts/buildpackage.py
tests/05_test_detection.py

old mode 100755 (executable)
new mode 100644 (file)
index 1f52b17..92d893a
@@ -429,10 +429,10 @@ def get_compression(orig_file):
     return None
 
 
-def has_orig(cp, compression, dir):
-    "Check if orig.tar.gz exists in dir"
+def has_orig(orig_file, dir):
+    "Check if orig tarball exists in dir"
     try:
-        os.stat( os.path.join(dir, orig_file(cp, compression)) )
+        os.stat( os.path.join(dir, orig_file) )
     except OSError:
         return False
     return True
index 1c166a8..89ef414 100755 (executable)
@@ -146,7 +146,7 @@ def prepare_upstream_tarball(repo, cp, options, tarball_dir, output_dir):
         else:
             gbp.log.info("Orig tarball '%s' found at '%s'" % (orig_file, tarball_dir))
     # build an orig unless the user forbids it, always build (and overwrite pre-existing) if user forces it
-    if options.force_create or (not options.no_create_orig and not du.has_orig(cp, options.comp_type, output_dir)):
+    if options.force_create or (not options.no_create_orig and not du.has_orig(orig_file, output_dir)):
         if not pristine_tar_build_orig(repo, cp, output_dir, options):
             git_archive_build_orig(repo, cp, output_dir, options)
 
@@ -381,7 +381,7 @@ def guess_comp_type(repo, comp_type, cp, tarball_dir):
                 tarball_dir = '..'
             detected = None
             for comp in du.compressor_opts.keys():
-                if du.has_orig(cp, comp, tarball_dir):
+                if du.has_orig(du.orig_file(cp, comp), tarball_dir):
                     if detected is not None:
                         raise GbpError, "Multiple orig tarballs found."
                     detected = comp
index d866d7d..c9cd16c 100644 (file)
@@ -8,7 +8,7 @@ import tempfile
 import unittest
 
 from gbp.scripts import buildpackage
-from gbp.deb import has_orig
+from gbp.deb import (has_orig, orig_file)
 from gbp.errors import GbpError
 
 class MockGitRepository:
@@ -66,11 +66,11 @@ class TestDetection(unittest.TestCase):
         self.assertEqual("bzip2", guessed)
 
     def test_has_orig_false(self):
-        self.assertFalse(has_orig(self.cp, 'gzip', self.tmpdir))
+        self.assertFalse(has_orig(orig_file(self.cp, 'gzip'), self.tmpdir))
 
     def test_has_orig_true(self):
         open(os.path.join(self.tmpdir, 'source_1.2.orig.tar.gz'), "w").close()
-        self.assertTrue(has_orig(self.cp, 'gzip', self.tmpdir))
+        self.assertTrue(has_orig(orig_file(self.cp, 'gzip'), self.tmpdir))
 
     def test_guess_comp_type_bzip2(self):
         repo = MockGitRepository(with_branch=False)