source-git: Add option to disable submodules

Closes: #295
Approved by: alexlarsson
auto
Linus Jahn 2019-07-20 12:26:35 +02:00 committed by Atomic Bot
parent 75c24ce291
commit 28aaaaa55e
2 changed files with 25 additions and 2 deletions

View File

@ -710,6 +710,10 @@
<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>
<varlistentry>
<term><option>disable-submodules</option> (boolean)</term>
<listitem><para>Don't checkout the git submodules when cloning the repository.</para></listitem>
</varlistentry>
</variablelist>
</refsect3>
<refsect3>

View File

@ -46,6 +46,7 @@ struct BuilderSourceGit
char *orig_ref;
gboolean disable_fsckobjects;
gboolean disable_shallow_clone;
gboolean disable_submodules;
};
typedef struct
@ -64,6 +65,7 @@ enum {
PROP_COMMIT,
PROP_DISABLE_FSCKOBJECTS,
PROP_DISABLE_SHALLOW_CLONE,
PROP_DISABLE_SUBMODULES,
LAST_PROP
};
@ -120,6 +122,10 @@ builder_source_git_get_property (GObject *object,
g_value_set_boolean (value, self->disable_shallow_clone);
break;
case PROP_DISABLE_SUBMODULES:
g_value_set_boolean (value, self->disable_submodules);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@ -168,6 +174,10 @@ builder_source_git_set_property (GObject *object,
self->disable_shallow_clone = g_value_get_boolean (value);
break;
case PROP_DISABLE_SUBMODULES:
self->disable_submodules = 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,
{
BuilderSourceGit *self = BUILDER_SOURCE_GIT (source);
g_autofree char *location = NULL;
FlatpakGitMirrorFlags flags;
FlatpakGitMirrorFlags flags = 0;
location = get_url_or_path (self, context, error);
if (location == NULL)
@ -235,7 +245,8 @@ builder_source_git_download (BuilderSource *source,
if (self->tag != NULL && self->branch != NULL)
return flatpak_fail (error, "Both tag (%s) and branch (%s) specified for git source", self->tag, self->branch);
flags = FLATPAK_GIT_MIRROR_FLAGS_MIRROR_SUBMODULES;
if (!self->disable_submodules)
flags |= FLATPAK_GIT_MIRROR_FLAGS_MIRROR_SUBMODULES;
if (update_vcs)
flags |= FLATPAK_GIT_MIRROR_FLAGS_UPDATE;
if (self->disable_fsckobjects)
@ -445,6 +456,14 @@ builder_source_git_class_init (BuilderSourceGitClass *klass)
"",
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_DISABLE_SUBMODULES,
g_param_spec_boolean ("disable-submodules",
"",
"",
FALSE,
G_PARAM_READWRITE));
}
static void