[oe-commits] [bitbake] 01/04: fetch2/git: prevent access to non-existing clonedir

git at git.openembedded.org git at git.openembedded.org
Tue Oct 16 20:21:03 UTC 2018


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository bitbake.

commit 21144715a67093650fad8fd87ab23efd52eb598b
Author: Urs Fässler <urs.fassler at bbv.ch>
AuthorDate: Mon Oct 8 08:15:10 2018 +0000

    fetch2/git: prevent access to non-existing clonedir
    
    A user friendly error is throw when neither the clonedir nor
    fullshallow exist. Without the check, a difficult to interpret error
    is throw from within the fetch command.
    
    Signed-off-by: Urs Fässler <urs.fassler at bbv.ch>
    Signed-off-by: Pascal Bach <pascal.bach at siemens.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/fetch2/git.py  |  4 +++-
 lib/bb/tests/fetch.py | 11 +++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index f13a25f..3e37f76 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -479,8 +479,10 @@ class Git(FetchMethod):
         if ud.shallow and os.path.exists(ud.fullshallow) and self.clonedir_need_update(ud, d):
             bb.utils.mkdirhier(destdir)
             runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=destdir)
-        else:
+        elif not self.clonedir_need_update(ud, d):
             runfetchcmd("%s clone %s %s/ %s" % (ud.basecmd, ud.cloneflags, ud.clonedir, destdir), d)
+        else:
+            raise bb.fetch2.UnpackError("No up to date source found", ud.url)
 
         repourl = self._get_repo_url(ud)
         runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, repourl), d, workdir=destdir)
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 9bed06b..f52241f 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -1699,6 +1699,17 @@ class GitShallowTest(FetcherTest):
         self.assertRefs(['master', 'origin/master'])
         self.assertRevCount(orig_revs - 1758)
 
+    def test_that_unpack_throws_an_error_when_the_git_clone_nor_shallow_tarball_exist(self):
+        self.add_empty_file('a')
+        fetcher, ud = self.fetch()
+        bb.utils.remove(self.gitdir, recurse=True)
+        bb.utils.remove(self.dldir, recurse=True)
+
+        with self.assertRaises(bb.fetch2.UnpackError) as context:
+            fetcher.unpack(self.d.getVar('WORKDIR'))
+
+        self.assertTrue("No up to date source found" in context.exception.msg)
+
     @skipIfNoNetwork()
     def test_that_unpack_does_work_when_using_git_shallow_tarball_but_tarball_is_not_available(self):
         self.d.setVar('SRCREV', 'e5939ff608b95cdd4d0ab0e1935781ab9a276ac0')

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list