aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2019-10-21 22:09:53 +0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-10-23 22:58:23 +0100
commit93b65e3c6ca64f644946953980595c44fbbcc748 (patch)
tree83c23590af69d68544ff02971a4943d8158bf30d
parent459ad524756a3f9b50feeedf31e33502dceae8d5 (diff)
downloadbitbake-93b65e3c6ca64f644946953980595c44fbbcc748.tar.gz
fetch2/git: fetch shallow revs when needed
When bitbake determines if a git clone needs updating, it only checks for the needed srcrevs, not the revs listed in BB_GIT_SHALLOW_REVS, which will fail if using shallow and the needed rev was added to the upstream git repo after a previous fetch. Ensure that we also check for shallow revs. [YOCTO #13586] Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/fetch2/git.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 2d1d2cabd..fa41b078f 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -292,11 +292,21 @@ class Git(FetchMethod):
def clonedir_need_update(self, ud, d):
if not os.path.exists(ud.clonedir):
return True
+ if ud.shallow and ud.write_shallow_tarballs and self.clonedir_need_shallow_revs(ud, d):
+ return True
for name in ud.names:
if not self._contains_ref(ud, d, name, ud.clonedir):
return True
return False
+ def clonedir_need_shallow_revs(self, ud, d):
+ for rev in ud.shallow_revs:
+ try:
+ runfetchcmd('%s rev-parse -q --verify %s' % (ud.basecmd, rev), d, quiet=True, workdir=ud.clonedir)
+ except bb.fetch2.FetchError:
+ return rev
+ return None
+
def shallow_tarball_need_update(self, ud):
return ud.shallow and ud.write_shallow_tarballs and not os.path.exists(ud.fullshallow)
@@ -339,13 +349,7 @@ class Git(FetchMethod):
runfetchcmd(clone_cmd, d, log=progresshandler)
# Update the checkout if needed
- needupdate = False
- for name in ud.names:
- if not self._contains_ref(ud, d, name, ud.clonedir):
- needupdate = True
- break
-
- if needupdate:
+ if self.clonedir_need_update(ud, d):
output = runfetchcmd("%s remote" % ud.basecmd, d, quiet=True, workdir=ud.clonedir)
if "origin" in output:
runfetchcmd("%s remote rm origin" % ud.basecmd, d, workdir=ud.clonedir)
@@ -369,6 +373,11 @@ class Git(FetchMethod):
if not self._contains_ref(ud, d, name, ud.clonedir):
raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
+ if ud.shallow and ud.write_shallow_tarballs:
+ missing_rev = self.clonedir_need_shallow_revs(ud, d)
+ if missing_rev:
+ raise bb.fetch2.FetchError("Unable to find revision %s even from upstream" % missing_rev)
+
def build_mirror_data(self, ud, d):
if ud.shallow and ud.write_shallow_tarballs:
if not os.path.exists(ud.fullshallow):