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

Checkout LFS objects #498

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
38 changes: 37 additions & 1 deletion src/builder-git.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,16 @@ builder_git_mirror_repo (const char *repo_location,
origin, full_ref_mapping, NULL))
return FALSE;

g_print ("Fetching LFS assets\n");
if (!git (mirror_dir, NULL, 0, error,
"lfs", "fetch", "--all", NULL))
{
git (mirror_dir, NULL, 0, error,
"lfs", "logs", "last", NULL);
return FALSE;
}


/* It turns out that older versions of git (at least 2.7.4)
* cannot check out a commit unless a real tag/branch points
* to it, which is not the case for e.g. gitbug pull requests.
Expand Down Expand Up @@ -606,6 +616,15 @@ builder_git_mirror_repo (const char *repo_location,
was_shallow ? "--unshallow" : NULL,
NULL))
return FALSE;

g_print ("Fetching LFS assets\n");
if (!git (mirror_dir, NULL, 0, error,
"lfs", "fetch", "--all", NULL))
{
git (mirror_dir, NULL, 0, error,
"lfs", "logs", "last", NULL);
return FALSE;
}
}

if (alternates)
Expand Down Expand Up @@ -708,6 +727,14 @@ builder_git_shallow_mirror_ref (const char *repo_location,
"fetch", "--depth", "1", "origin", full_ref_colon_full_ref, NULL))
return FALSE;

if (!git (mirror_dir, NULL, 0, error,
"lfs", "fetch", "origin", full_ref, NULL))
{
git (mirror_dir, NULL, 0, error,
"lfs", "logs", "last", NULL);
return FALSE;
}

/* Always mirror submodules */
current_commit = git_get_current_commit (mirror_dir, ref, FALSE, context, error);
if (current_commit == NULL)
Expand Down Expand Up @@ -858,10 +885,19 @@ builder_git_checkout (const char *repo_location,
"config", "--bool", "core.bare", "false", NULL))
return FALSE;

if (!git (dest, NULL, 0, error,
"lfs", "install", NULL))
return FALSE;

if (!git (dest, NULL, 0, error,
"checkout", branch, NULL))
return FALSE;

if (!git (dest, NULL, 0, error,
"lfs", "checkout", NULL))
return FALSE;


if (mirror_flags & FLATPAK_GIT_MIRROR_FLAGS_MIRROR_SUBMODULES)
if (!git_extract_submodule (repo_location, dest, branch, context, error))
return FALSE;
Expand Down Expand Up @@ -897,4 +933,4 @@ builder_git_get_default_branch (const char *repo_location)

g_debug ("Failed to auto-detect default branch from git output");
return g_strdup ("master");
}
}