aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-08-02 15:27:28 -0300
committerGuido Günther <agx@sigxcpu.org>2017-08-02 15:27:28 -0300
commit6b326e2e5c7d6c9899e6d196fc7fb96af2c0d207 (patch)
treedca5dc0903537b373a37adcc946f89c86b2df66b
parent864c30905f865e9d407e5830d63cbd3c8cc5a8cf (diff)
pristine-tar: add feature detection
so we can run tests with older pristine-tar not supporting verify
-rw-r--r--gbp/pkg/pristinetar.py20
-rw-r--r--tests/doctests/test_PristineTar.py3
2 files changed, 22 insertions, 1 deletions
diff --git a/gbp/pkg/pristinetar.py b/gbp/pkg/pristinetar.py
index 4b7a87ee..cd7c5123 100644
--- a/gbp/pkg/pristinetar.py
+++ b/gbp/pkg/pristinetar.py
@@ -16,6 +16,7 @@
# <http://www.gnu.org/licenses/>
"""Handle checkin and checkout of archives from the pristine-tar branch"""
+import re
import os
import gbp.log
from gbp.command_wrappers import Command
@@ -30,6 +31,25 @@ class PristineTar(Command):
self.repo = repo
super(PristineTar, self).__init__(self.cmd, cwd=repo.path, capture_stderr=True)
+ def _has_feature(self, feature):
+ """
+ Check if pristine_tar has a certain feature enabled.
+
+ @param feature: feature / command option to check
+ @type feature: C{str}
+ @return: True if feature is supported
+ @rtype: C{bool}
+ """
+ self.call(['--help'], quiet=True) # There's no --help so we always exit 1
+ r = re.compile('.* pristine-tar .* %s' % feature)
+ for line in self.stderr.splitlines():
+ if r.match(line):
+ return True
+ return False
+
+ def has_feature_verify(self):
+ return self._has_feature("verify")
+
def has_commit(self, archive_regexp):
"""
Do we have a pristine-tar commit for a package matching I{archive_regexp}.
diff --git a/tests/doctests/test_PristineTar.py b/tests/doctests/test_PristineTar.py
index 95472877..dffb4491 100644
--- a/tests/doctests/test_PristineTar.py
+++ b/tests/doctests/test_PristineTar.py
@@ -146,7 +146,8 @@ def test_pristine_tar_verify():
>>> import gbp.deb.git
>>> repo = gbp.deb.git.DebianGitRepository(dirs['repo'])
- >>> repo.pristine_tar.verify('../upstream_1.0.orig.tar.gz')
+ >>> if repo.pristine_tar.has_feature_verify():
+ ... repo.pristine_tar.verify('../upstream_1.0.orig.tar.gz')
"""