Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only fetch lfs files for specific git_ref #5202

Merged
merged 5 commits into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions conda_build/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,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
)


Expand Down Expand Up @@ -273,8 +273,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,
Expand Down Expand Up @@ -318,8 +318,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, 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
# know how to normalize it. Need to convert it to a windows path.
Expand Down
Loading