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_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 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 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; g_autofree char *location = NULL; location = get_url_or_path (self, context, error); if (location == NULL) return FALSE; if (!git_mirror_repo (location, update_vcs, get_branch (self), context, error)) return FALSE; return TRUE; }