diff options
author | Christopher Larson <chris_larson@mentor.com> | 2019-10-21 22:09:53 +0500 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2019-11-23 07:48:02 -0800 |
commit | 24e3c7189e7d41bcbb46078a41c3a9daf391202a (patch) | |
tree | 53c3177c7362aaf5fe193741a4573dbf596c289a | |
parent | 1a79651c518abc35b99005c137ab7e82a99c75b0 (diff) | |
download | bitbake-24e3c7189e7d41bcbb46078a41c3a9daf391202a.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>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r-- | lib/bb/fetch2/git.py | 23 |
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): |