aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-04-25 23:34:59 +0200
committerGuido Günther <agx@sigxcpu.org>2017-04-26 07:15:19 +0200
commit1375fd4705b40a0f0d1f68b42ebcb2bbe02b31fe (patch)
tree042dd8502414fea987484ffc1a8190a7006ef629
parenta4667c717d236ab9b4572dedd92d532eb14c5645 (diff)
clone: don't print exception when we can't find the source package
-rwxr-xr-xgbp/scripts/clone.py7
-rw-r--r--tests/component/deb/test_clone.py9
2 files changed, 13 insertions, 3 deletions
diff --git a/gbp/scripts/clone.py b/gbp/scripts/clone.py
index a06307d..04836f7 100755
--- a/gbp/scripts/clone.py
+++ b/gbp/scripts/clone.py
@@ -42,7 +42,7 @@ def apt_showsrc(pkg):
aptsrc(quiet=True)
return aptsrc.stdout
except CommandExecFailed:
- gbp.log.err("Can't find source package for '%s'" % pkg)
+ return ''
def vcs_git_url(pkg):
@@ -70,7 +70,8 @@ def vcs_git_url(pkg):
version = repo = None
if not repos:
- raise GbpError("Can't find a source package for '%s'" % pkg)
+ gbp.log.err("Can't find a source package for '%s'" % pkg)
+ return None
s = sorted(repos, key=cmp_to_key(DpkgCompareVersions()))
return repos[s[-1]]
@@ -158,6 +159,8 @@ def main(argv):
return 1
else:
source = repo_to_url(args[1])
+ if not source:
+ return 1
clone_to, auto_name = (os.path.curdir, True) if len(args) < 3 else (args[2], False)
try:
diff --git a/tests/component/deb/test_clone.py b/tests/component/deb/test_clone.py
index 91e0cd1..6a5b8df 100644
--- a/tests/component/deb/test_clone.py
+++ b/tests/component/deb/test_clone.py
@@ -57,7 +57,7 @@ class TestClone(ComponentTestBase):
self.check_hook_vars('postclone', ["GBP_GIT_DIR"])
@skipUnless(os.getenv("GBP_NETWORK_TESTS"), "network tests disabled")
- def test_clone_vcsgit(self):
+ def test_clone_vcsgit_ok(self):
"""Test that cloning from vcs-git urls works"""
dest = os.path.join(self._tmpdir,
'cloned_repo')
@@ -67,6 +67,13 @@ class TestClone(ComponentTestBase):
self._check_repo_state(cloned, 'debian/sid', ['debian/sid', 'upstream/latest'])
@skipUnless(os.getenv("GBP_NETWORK_TESTS"), "network tests disabled")
+ def test_clone_vcsgit_fail(self):
+ """Test that cloning from vcs-git urls fails as expected"""
+ ret = clone(['arg0', "vcsgit:doesnotexist"])
+ self.assertEquals(ret, 1)
+ self._check_log(-1, "gbp:error: Can't find a source package for 'doesnotexist'")
+
+ @skipUnless(os.getenv("GBP_NETWORK_TESTS"), "network tests disabled")
def test_clone_github(self):
"""Test that cloning from github urls works"""
dest = os.path.join(self._tmpdir,