Skip to contentSkip to conversation

bitbake: fetch2: git: Update Git-LFS download and tests

PATCH New Desone Burns II 1 participant 1 message Nov 3, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitbake: fetch2: git: Update Git-LFS download and tests

When downloading a Git repository containing an LFS, the Git hooks are not always initialized correctly to perform the download. This change updates the Git downloader to run the "git lfs install" command in order to "smudge" the LFS files. The tests have also been updated to do checks for situations in which git lfs is not installed, as the application was required to be installed for any of the tests to run previously.

The Git LFS functionality was working to some degree previously, but this change also updates the fetcher to allow LFS downloads for nobranch SRC_URIs.

---
 bitbake/lib/bb/fetch2/git.py  | 14 ++++++--
 bitbake/lib/bb/tests/fetch.py | 61 ++++++++++++++++++++---------------
 2 files changed, 47 insertions(+), 28 deletions(-)
bitbake/lib/bb/fetch2/git.py +12 -2
index 27a0d05144..5fb573a381 100644
@@ -52,6 +52,11 @@ Supported SRC_URI options are:
    For local git:// urls to use the current branch HEAD as the revision for use with
    AUTOREV. Implies nobranch.
 
+- lfs
+    Enable the checkout to use LFS for large files. This will download all LFS files
+    in the download step, as the unpack step does not have network access.
+    The default is "1", set lfs=0 to skip.
+
 """
 
 # Copyright (C) 2005 Richard Purdie
@@ -629,6 +634,8 @@ class Git(FetchMethod):
                 raise bb.fetch2.FetchError("Repository %s has LFS content, install git-lfs on host to download (or set lfs=0 to ignore it)" % (repourl))
             elif not need_lfs:
                 bb.note("Repository %s has LFS content but it is not being fetched" % (repourl))
+            else:
+                runfetchcmd("%s lfs install" % ud.basecmd, d, workdir=destdir)
 
         if not ud.nocheckout:
             if subpath:
@@ -688,8 +695,11 @@ class Git(FetchMethod):
         Check if the repository has 'lfs' (large file) content
         """
 
-        # The bare clonedir doesn't use the remote names; it has the branch immediately.
-        if wd == ud.clonedir:
+        if ud.nobranch:
+            # If no branch is specified, use the current git commit
+            refname = self._build_revision(ud, d, ud.names[0])
+        elif wd == ud.clonedir:
+            # The bare clonedir doesn't use the remote names; it has the branch immediately.
             refname = ud.branches[ud.names[0]]
         else:
             refname = "origin/%s" % ud.branches[ud.names[0]]
bitbake/lib/bb/tests/fetch.py +35 -26

95 lines not on this page · raw message

Signature · 1 line
2.25.1