Skip to contentSkip to conversation

fetch/git: fix AttributeError in shallow extraction logic

PATCH New Christopher Larson 1 participant 1 message Nov 21, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch/git: fix AttributeError in shallow extraction logic

From: Christopher Larson <[email protected]>

This code checks to see if shallow is either disabled or the tarball is missing, but the else block tries to print the tarball filename, and this attribute doesn't exist at all when shallow is disabled. Handle the two cases separately to give sane errors for both cases without the exception:

Exception: AttributeError: 'FetchData' object has no attribute 'fullshallow'

---
 lib/bb/fetch2/git.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
lib/bb/fetch2/git.py +8 -5
index 15858a62..59a2ee8f 100644
@@ -488,12 +488,15 @@ class Git(FetchMethod):
                 source_error.append("clone directory not available or not up to date: " + ud.clonedir)
 
         if not source_found:
-            if ud.shallow and os.path.exists(ud.fullshallow):
-                bb.utils.mkdirhier(destdir)
-                runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=destdir)
-                source_found = True
+            if ud.shallow:
+                if os.path.exists(ud.fullshallow):
+                    bb.utils.mkdirhier(destdir)
+                    runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=destdir)
+                    source_found = True
+                else:
+                    source_error.append("shallow clone not available: " + ud.fullshallow)
             else:
-                source_error.append("shallow clone not enabled or not available: " + ud.fullshallow)
+                source_error.append("shallow clone not enabled")
 
         if not source_found:
             raise bb.fetch2.UnpackError("No up to date source found: " + "; ".join(source_error), ud.url)
Signature · 1 line
2.11.1