summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2019-10-26 12:02:30 +0200
committerGuido Günther <agx@sigxcpu.org>2019-10-26 12:02:30 +0200
commit62485247b61090f8bd41a8bf419872db36fa12dc (patch)
tree18f75f70d862e471598b295fbb0cc1624932a601
parentd21627cb031a38b3d9a052e2d931853f04fb8fff (diff)
export_orig: Don't fail without a repository
This is a valid use case in overlay mode Thanks: Thomas Koch for the report
-rwxr-xr-xgbp/scripts/export_orig.py11
-rw-r--r--tests/05_test_detection.py5
2 files changed, 11 insertions, 5 deletions
diff --git a/gbp/scripts/export_orig.py b/gbp/scripts/export_orig.py
index c2885014..13be4f91 100755
--- a/gbp/scripts/export_orig.py
+++ b/gbp/scripts/export_orig.py
@@ -236,12 +236,13 @@ def guess_comp_type(comp_type, source, repo, tarball_dir):
if comp_type == 'auto':
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 repo:
+ if repo.has_branch('pristine-tar'):
+ branch = 'pristine-tar'
+ elif repo.has_branch('origin/pristine-tar', remote=True):
+ branch = 'origin/pristine-tar'
- if branch:
+ if branch is not None:
regex = r'pristine-tar .* %s_%s\.orig.tar\.' % (source.name, source.upstream_version)
commits = repo.grep_log(regex, branch, merges=False)
if commits:
diff --git a/tests/05_test_detection.py b/tests/05_test_detection.py
index d6322335..c4831fbf 100644
--- a/tests/05_test_detection.py
+++ b/tests/05_test_detection.py
@@ -139,3 +139,8 @@ class TestDetection(unittest.TestCase):
guessed = export_orig.guess_comp_type(
'gz', self.source, repo, None)
self.assertEqual("gzip", guessed)
+
+ def test_guess_comp_type_no_repo(self):
+ guessed = export_orig.guess_comp_type(
+ 'auto', self.source, None, str(self.tmpdir))
+ self.assertEqual('gzip', guessed)