forked from Mirrors/flatpak-builder
Add option to disable shallow clone for git sources
Closes: #55 Approved by: alexlarssontingping/wmclass
parent
fb2612ea02
commit
ac6a25c981
|
@ -552,6 +552,10 @@
|
|||
<term><option>disable-fsckobjects</option> (boolean)</term>
|
||||
<listitem><para>Don't use transfer.fsckObjects=1 to mirror git repository. This may be needed for some (broken) repositories.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>disable-shallow-clone</option> (boolean)</term>
|
||||
<listitem><para>Don't optimize by making a shallow clone when downloading the git repo.</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect3>
|
||||
<refsect3>
|
||||
|
|
|
@ -219,6 +219,7 @@ git_mirror_submodules (const char *repo_location,
|
|||
gboolean update,
|
||||
GFile *mirror_dir,
|
||||
gboolean disable_fsck,
|
||||
gboolean disable_shallow,
|
||||
const char *revision,
|
||||
BuilderContext *context,
|
||||
GError **error)
|
||||
|
@ -291,7 +292,7 @@ git_mirror_submodules (const char *repo_location,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!builder_git_mirror_repo (absolute_url, destination_path, update, TRUE, disable_fsck, words[2], context, error))
|
||||
if (!builder_git_mirror_repo (absolute_url, destination_path, update, TRUE, disable_fsck, disable_shallow, words[2], context, error))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -313,6 +314,7 @@ builder_git_mirror_repo (const char *repo_location,
|
|||
gboolean update,
|
||||
gboolean mirror_submodules,
|
||||
gboolean disable_fsck,
|
||||
gboolean disable_shallow,
|
||||
const char *ref,
|
||||
BuilderContext *context,
|
||||
GError **error)
|
||||
|
@ -390,15 +392,16 @@ builder_git_mirror_repo (const char *repo_location,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
full_ref = lookup_full_ref (refs, ref);
|
||||
if (!git (mirror_dir, NULL, 0, error,
|
||||
"config", "transfer.fsckObjects", disable_fsck ? "0" : "1", NULL))
|
||||
return FALSE;
|
||||
|
||||
if (!disable_shallow)
|
||||
full_ref = lookup_full_ref (refs, ref);
|
||||
if (full_ref)
|
||||
{
|
||||
g_autofree char *full_ref_mapping = g_strdup_printf ("+%s:%s", full_ref, full_ref);
|
||||
|
||||
if (!git (mirror_dir, NULL, 0, error,
|
||||
"config", "transfer.fsckObjects", disable_fsck ? "0" : "1", NULL))
|
||||
return FALSE;
|
||||
|
||||
g_print ("Fetching git repo %s, ref %s\n", repo_location, full_ref);
|
||||
if (!git (mirror_dir, NULL, 0, error,
|
||||
"fetch", "-p", "--no-recurse-submodules", "--no-tags", "--depth=1", "-f",
|
||||
|
@ -421,8 +424,8 @@ builder_git_mirror_repo (const char *repo_location,
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
else if (!already_exists)
|
||||
/* We don't fetch everything if it already exists, because
|
||||
else if (!already_exists || disable_shallow)
|
||||
/* We don't fetch everything if it already exists (and we're not disabling shallow), because
|
||||
since it failed to resolve to full_ref it is a commit id
|
||||
which can't change and thus need no updates */
|
||||
{
|
||||
|
@ -450,7 +453,7 @@ builder_git_mirror_repo (const char *repo_location,
|
|||
return FALSE;
|
||||
|
||||
if (!git_mirror_submodules (repo_location, destination_path, FALSE, update,
|
||||
mirror_dir, disable_fsck, current_commit, context, error))
|
||||
mirror_dir, disable_fsck, disable_shallow, current_commit, context, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -525,7 +528,7 @@ builder_git_shallow_mirror_ref (const char *repo_location,
|
|||
return FALSE;
|
||||
|
||||
if (!git_mirror_submodules (repo_location, destination_path, TRUE, FALSE,
|
||||
mirror_dir, TRUE, current_commit, context, error))
|
||||
mirror_dir, TRUE, FALSE, current_commit, context, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ gboolean builder_git_mirror_repo (const char *repo_location,
|
|||
gboolean update,
|
||||
gboolean mirror_submodules,
|
||||
gboolean disable_fsck,
|
||||
gboolean disable_shallow,
|
||||
const char *ref,
|
||||
BuilderContext *context,
|
||||
GError **error);
|
||||
|
|
|
@ -434,7 +434,7 @@ main (int argc,
|
|||
|
||||
if (!builder_git_mirror_repo (opt_from_git,
|
||||
NULL,
|
||||
!opt_disable_updates, FALSE, FALSE,
|
||||
!opt_disable_updates, FALSE, FALSE, FALSE,
|
||||
git_branch, build_context, &error))
|
||||
{
|
||||
g_printerr ("Can't clone manifest repo: %s\n", error->message);
|
||||
|
|
|
@ -45,6 +45,7 @@ struct BuilderSourceGit
|
|||
char *commit;
|
||||
char *orig_ref;
|
||||
gboolean disable_fsckobjects;
|
||||
gboolean disable_shallow_clone;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
|
@ -62,6 +63,7 @@ enum {
|
|||
PROP_TAG,
|
||||
PROP_COMMIT,
|
||||
PROP_DISABLE_FSCKOBJECTS,
|
||||
PROP_DISABLE_SHALLOW_CLONE,
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
|
@ -114,6 +116,10 @@ builder_source_git_get_property (GObject *object,
|
|||
g_value_set_boolean (value, self->disable_fsckobjects);
|
||||
break;
|
||||
|
||||
case PROP_DISABLE_SHALLOW_CLONE:
|
||||
g_value_set_boolean (value, self->disable_shallow_clone);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
|
@ -158,6 +164,10 @@ builder_source_git_set_property (GObject *object,
|
|||
self->disable_fsckobjects = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_DISABLE_SHALLOW_CLONE:
|
||||
self->disable_shallow_clone = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
|
@ -226,7 +236,7 @@ builder_source_git_download (BuilderSource *source,
|
|||
|
||||
if (!builder_git_mirror_repo (location,
|
||||
NULL,
|
||||
update_vcs, TRUE, self->disable_fsckobjects,
|
||||
update_vcs, TRUE, self->disable_fsckobjects, self->disable_shallow_clone,
|
||||
get_branch (self),
|
||||
context,
|
||||
error))
|
||||
|
@ -316,6 +326,8 @@ builder_source_git_checksum (BuilderSource *source,
|
|||
builder_cache_checksum_str (cache, self->branch);
|
||||
builder_cache_checksum_str (cache, self->commit);
|
||||
builder_cache_checksum_boolean (cache, self->disable_fsckobjects);
|
||||
/* We don't checksum disable_shallow_clone, because it doesn't have
|
||||
any effect on the resultant build */
|
||||
|
||||
location = get_url_or_path (self, context, &error);
|
||||
if (location != NULL)
|
||||
|
@ -418,6 +430,13 @@ builder_source_git_class_init (BuilderSourceGitClass *klass)
|
|||
"",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE));
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_DISABLE_SHALLOW_CLONE,
|
||||
g_param_spec_boolean ("disable-shallow-clone",
|
||||
"",
|
||||
"",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue