static gboolean builder_source_git_update (BuilderSource *source, BuilderContext *context, GError **error) { BuilderSourceGit *self = BUILDER_SOURCE_GIT (source); g_autoptr(GFile) mirror_dir = NULL; char *current_commit; g_autofree char *location = NULL; location = get_url_or_path (self, context, error); if (location == NULL) return FALSE; mirror_dir = git_get_mirror_dir (location, context); current_commit = git_get_current_commit (mirror_dir, get_branch (self), context, NULL); if (current_commit) { g_free (self->branch); self->branch = current_commit; } return TRUE; }
static void builder_source_git_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { BuilderSourceGit *self = BUILDER_SOURCE_GIT (object); switch (prop_id) { case PROP_URL: g_value_set_string (value, self->url); break; case PROP_PATH: g_value_set_string (value, self->path); break; case PROP_BRANCH: g_value_set_string (value, self->branch); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } }
static gboolean builder_source_git_bundle (BuilderSource *source, BuilderContext *context, GError **error) { BuilderSourceGit *self = BUILDER_SOURCE_GIT (source); g_autofree char *location = NULL; g_autoptr(GFile) mirror_dir = NULL; location = get_url_or_path (self, context, error); g_print ("builder_source_git_bundle %s\n", location); if (location == NULL) return FALSE; mirror_dir = flatpak_build_file (builder_context_get_app_dir (context), "sources/git", NULL); if (!flatpak_mkdir_p (mirror_dir, NULL, error)) return FALSE; if (!builder_git_mirror_repo (location, flatpak_file_get_path_cached (mirror_dir), FALSE, TRUE, FALSE, get_branch (self), context, error)) return FALSE; return TRUE; }
static void builder_source_git_checksum (BuilderSource *source, BuilderCache *cache, BuilderContext *context) { BuilderSourceGit *self = BUILDER_SOURCE_GIT (source); g_autoptr(GFile) mirror_dir = NULL; g_autofree char *current_commit = NULL; g_autoptr(GError) error = NULL; g_autofree char *location = NULL; builder_cache_checksum_str (cache, self->url); builder_cache_checksum_str (cache, self->path); builder_cache_checksum_str (cache, self->branch); location = get_url_or_path (self, context, &error); if (location != NULL) { mirror_dir = git_get_mirror_dir (location, context); current_commit = git_get_current_commit (mirror_dir, get_branch (self), context, &error); if (current_commit) builder_cache_checksum_str (cache, current_commit); else if (error) g_warning ("Failed to get current git checksum: %s", error->message); } else { g_warning ("No url or path"); } }
static gboolean builder_source_git_download (BuilderSource *source, gboolean update_vcs, BuilderContext *context, GError **error) { BuilderSourceGit *self = BUILDER_SOURCE_GIT (source); g_autofree char *location = NULL; location = get_url_or_path (self, context, error); if (location == NULL) return FALSE; if (!builder_git_mirror_repo (location, NULL, update_vcs, TRUE, self->disable_fsckobjects, get_branch (self), context, error)) return FALSE; if (self->commit != NULL && self->branch != NULL) { g_autofree char *current_commit = builder_git_get_current_commit (location,get_branch (self), context, error); if (current_commit == NULL) return FALSE; if (strcmp (current_commit, self->commit) != 0) return flatpak_fail (error, "Git commit for branch %s is %s, but expected %s\n", self->branch, current_commit, self->commit); } return TRUE; }
static gboolean builder_source_git_extract (BuilderSource *source, GFile *dest, BuilderOptions *build_options, BuilderContext *context, GError **error) { BuilderSourceGit *self = BUILDER_SOURCE_GIT (source); g_autofree char *location = NULL; location = get_url_or_path (self, context, error); if (location == NULL) return FALSE; if (!builder_git_checkout (location, get_branch (self), dest, context, error)) return FALSE; return TRUE; }
static gboolean builder_source_git_extract (BuilderSource *source, GFile *dest, BuilderContext *context, GError **error) { BuilderSourceGit *self = BUILDER_SOURCE_GIT (source); g_autoptr(GFile) mirror_dir = NULL; g_autofree char *mirror_dir_path = NULL; g_autofree char *dest_path = NULL; g_autofree char *location = NULL; location = get_url_or_path (self, context, error); if (location == NULL) return FALSE; mirror_dir = git_get_mirror_dir (location, context); mirror_dir_path = g_file_get_path (mirror_dir); dest_path = g_file_get_path (dest); if (!git (NULL, NULL, error, "clone", mirror_dir_path, dest_path, NULL)) return FALSE; if (!git (dest, NULL, error, "checkout", get_branch (self), NULL)) return FALSE; if (!git_extract_submodule (location, dest, context, error)) return FALSE; if (!git (dest, NULL, error, "config", "--local", "remote.origin.url", location, NULL)) return FALSE; return TRUE; }
static gboolean builder_source_git_download (BuilderSource *source, gboolean update_vcs, BuilderContext *context, GError **error) { BuilderSourceGit *self = BUILDER_SOURCE_GIT (source); g_autofree char *url = NULL; url = get_url (self, context, error); if (url == NULL) return FALSE; if (!git_mirror_repo (url, update_vcs, get_branch (self), context, error)) return FALSE; return TRUE; }
static void builder_source_git_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { BuilderSourceGit *self = BUILDER_SOURCE_GIT (object); switch (prop_id) { case PROP_URL: g_free (self->url); self->url = g_value_dup_string (value); break; case PROP_PATH: g_free (self->path); self->path = g_value_dup_string (value); break; case PROP_BRANCH: g_free (self->branch); self->branch = g_value_dup_string (value); break; case PROP_COMMIT: g_free (self->commit); self->commit = g_value_dup_string (value); break; case PROP_DISABLE_FSCKOBJECTS: self->disable_fsckobjects = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } }