From 932a00dcf90b4315cedf62cff301ce4ffd540d66 Mon Sep 17 00:00:00 2001 From: Tobias Fischer Date: Thu, 29 Feb 2024 10:03:09 +1000 Subject: [PATCH 1/2] Only fetch lfs files for specific git_ref --- conda_build/source.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/conda_build/source.py b/conda_build/source.py index d4e1ca5b69..4e0ed1f09d 100644 --- a/conda_build/source.py +++ b/conda_build/source.py @@ -201,19 +201,19 @@ def unpack( shutil.move(os.path.join(tmpdir, f), os.path.join(src_dir, f)) -def check_git_lfs(git, cwd): +def check_git_lfs(git, cwd, git_ref): try: - lfs_list_output = check_output_env([git, "lfs", "ls-files", "--all"], cwd=cwd) + lfs_list_output = check_output_env([git, "lfs", "ls-files", git_ref], cwd=cwd) return lfs_list_output and lfs_list_output.strip() except CalledProcessError: return False -def git_lfs_fetch(git, cwd, stdout, stderr): +def git_lfs_fetch(git, cwd, git_ref, stdout, stderr): lfs_version = check_output_env([git, "lfs", "version"], cwd=cwd) log.info(lfs_version) check_call_env( - [git, "lfs", "fetch", "origin", "--all"], cwd=cwd, stdout=stdout, stderr=stderr + [git, "lfs", "fetch", "origin", git_ref], cwd=cwd, stdout=stdout, stderr=stderr ) @@ -317,8 +317,8 @@ def git_mirror_checkout_recursive( check_call_env( args + [git_url, git_mirror_dir], stdout=stdout, stderr=stderr ) - if check_git_lfs(git, mirror_dir): - git_lfs_fetch(git, mirror_dir, stdout, stderr) + if check_git_lfs(git, git_ref, mirror_dir): + git_lfs_fetch(git, mirror_dir, git_ref, stdout, stderr) except CalledProcessError: # on windows, remote URL comes back to us as cygwin or msys format. Python doesn't # know how to normalize it. Need to convert it to a windows path. From 50f57752f8814818e755e879fec0682a1ec58ec8 Mon Sep 17 00:00:00 2001 From: Tobias Fischer Date: Thu, 29 Feb 2024 13:09:26 +1000 Subject: [PATCH 2/2] Bugfixes --- conda_build/source.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conda_build/source.py b/conda_build/source.py index 4e0ed1f09d..3c3ddec5aa 100644 --- a/conda_build/source.py +++ b/conda_build/source.py @@ -272,8 +272,8 @@ def git_mirror_checkout_recursive( check_call_env( [git, "fetch"], cwd=mirror_dir, stdout=stdout, stderr=stderr ) - if check_git_lfs(git, mirror_dir): - git_lfs_fetch(git, mirror_dir, stdout, stderr) + if check_git_lfs(git, mirror_dir, git_ref): + git_lfs_fetch(git, mirror_dir, git_ref, stdout, stderr) else: # Unlike 'git clone', fetch doesn't automatically update the cache's HEAD, # So here we explicitly store the remote HEAD in the cache's local refs/heads, @@ -317,7 +317,7 @@ def git_mirror_checkout_recursive( check_call_env( args + [git_url, git_mirror_dir], stdout=stdout, stderr=stderr ) - if check_git_lfs(git, git_ref, mirror_dir): + if check_git_lfs(git, mirror_dir, git_ref): git_lfs_fetch(git, mirror_dir, git_ref, stdout, stderr) except CalledProcessError: # on windows, remote URL comes back to us as cygwin or msys format. Python doesn't