From 28aaaaa55eac64831df18df9a3a7c3388e65b68d Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Sat, 20 Jul 2019 12:26:35 +0200 Subject: [PATCH] source-git: Add option to disable submodules Closes: #295 Approved by: alexlarsson --- doc/flatpak-manifest.xml | 4 ++++ src/builder-source-git.c | 23 +++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/doc/flatpak-manifest.xml b/doc/flatpak-manifest.xml index c7faabb7..ad54a463 100644 --- a/doc/flatpak-manifest.xml +++ b/doc/flatpak-manifest.xml @@ -710,6 +710,10 @@ (boolean) Don't optimize by making a shallow clone when downloading the git repo. + + (boolean) + Don't checkout the git submodules when cloning the repository. + diff --git a/src/builder-source-git.c b/src/builder-source-git.c index 7dd72f4f..aa038657 100644 --- a/src/builder-source-git.c +++ b/src/builder-source-git.c @@ -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