diff options
author | Ross Burton <ross.burton@intel.com> | 2019-09-19 23:43:36 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-09-27 13:02:19 +0100 |
commit | 560358e922b5663d9ae6495143f088e0a4b66e03 (patch) | |
tree | 25ba2af5c17d62331582e0bdb4b09fe2dd8d7a80 /bitbake | |
parent | 2c58079222310443f08df51e9fd6ce234e7e0019 (diff) | |
download | poky-560358e922b5663d9ae6495143f088e0a4b66e03.tar.gz |
bitbake: fetch2/git: refactor check for git-lfs command
Refactor the git-lfs checking: this means both clearer code in the download()
function and allows unit testing to monkeypatch the functionality.
(Bitbake rev: 33cf9172ded50a869f7201ba463ab9ecc69b8252)
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index 5fd63b4e33..2d1d2cabd5 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
@@ -495,14 +495,8 @@ class Git(FetchMethod): | |||
495 | runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, repourl), d, workdir=destdir) | 495 | runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, repourl), d, workdir=destdir) |
496 | 496 | ||
497 | if self._contains_lfs(ud, d, destdir): | 497 | if self._contains_lfs(ud, d, destdir): |
498 | if need_lfs: | 498 | if need_lfs and not self._find_git_lfs(d): |
499 | path = d.getVar('PATH') | 499 | raise bb.fetch2.FetchError("Repository %s has LFS content, install git-lfs on host to download (or set lfs=0 to ignore it)" % (repourl)) |
500 | if path: | ||
501 | gitlfstool = bb.utils.which(path, "git-lfs", executable=True) | ||
502 | if not gitlfstool: | ||
503 | raise bb.fetch2.FetchError("Repository %s has LFS content, install git-lfs on host to download (or set lfs=0 to ignore it)" % (repourl)) | ||
504 | else: | ||
505 | bb.note("Could not find 'PATH'") | ||
506 | else: | 500 | else: |
507 | bb.note("Repository %s has LFS content but it is not being fetched" % (repourl)) | 501 | bb.note("Repository %s has LFS content but it is not being fetched" % (repourl)) |
508 | 502 | ||
@@ -570,6 +564,13 @@ class Git(FetchMethod): | |||
570 | pass | 564 | pass |
571 | return False | 565 | return False |
572 | 566 | ||
567 | def _find_git_lfs(self, d): | ||
568 | """ | ||
569 | Return True if git-lfs can be found, False otherwise. | ||
570 | """ | ||
571 | import shutil | ||
572 | return shutil.which("git-lfs", path=d.getVar('PATH')) is not None | ||
573 | |||
573 | def _get_repo_url(self, ud): | 574 | def _get_repo_url(self, ud): |
574 | """ | 575 | """ |
575 | Return the repository URL | 576 | Return the repository URL |