summaryrefslogtreecommitdiff
path: root/builder/builder-cache.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2016-01-18 15:22:56 +0100
committerAlexander Larsson <alexl@redhat.com>2016-01-18 15:22:56 +0100
commite91a4c79e05297c9754c8e022ec94f717512f59a (patch)
treef6268565dee218ba60e14edc6b8d3e0c2410d463 /builder/builder-cache.c
parent3341fb08adc981879043445e8c40883786705738 (diff)
downloadxdg-app-e91a4c79e05297c9754c8e022ec94f717512f59a.tar.gz
Builder: Support commiting a platform
Diffstat (limited to 'builder/builder-cache.c')
-rw-r--r--builder/builder-cache.c72
1 files changed, 66 insertions, 6 deletions
diff --git a/builder/builder-cache.c b/builder/builder-cache.c
index 4bf17f6..2537f94 100644
--- a/builder/builder-cache.c
+++ b/builder/builder-cache.c
@@ -491,15 +491,68 @@ builder_cache_get_outstanding_changes (BuilderCache *self,
return TRUE;
}
-
GPtrArray *
-builder_cache_get_changes (BuilderCache *self,
- GError **error)
+builder_cache_get_all_changes (BuilderCache *self,
+ GError **error)
{
g_autoptr(GPtrArray) added = g_ptr_array_new_with_free_func (g_object_unref);
g_autoptr(GPtrArray) modified = g_ptr_array_new_with_free_func ((GDestroyNotify)ostree_diff_item_unref);
g_autoptr(GPtrArray) removed = g_ptr_array_new_with_free_func (g_object_unref);
- g_autoptr(GPtrArray) added_paths = g_ptr_array_new_with_free_func (g_free);
+ g_autoptr(GPtrArray) all_paths = g_ptr_array_new_with_free_func (g_free);
+ g_autoptr(GFile) init_root = NULL;
+ g_autoptr(GFile) finish_root = NULL;
+ g_autoptr(GVariant) variant = NULL;
+ g_autofree char *init_commit = NULL;
+ g_autofree char *finish_commit = NULL;
+ int i;
+ g_autofree char *init_ref = get_ref (self, "init");
+ g_autofree char *finish_ref = get_ref (self, "finish");
+
+ if (!ostree_repo_resolve_rev (self->repo, init_ref, FALSE, &init_commit, NULL))
+ return FALSE;
+
+ if (!ostree_repo_resolve_rev (self->repo, finish_ref, FALSE, &finish_commit, NULL))
+ return FALSE;
+
+ if (!ostree_repo_read_commit (self->repo, init_commit, &init_root, NULL, NULL, error))
+ return NULL;
+
+ if (!ostree_repo_read_commit (self->repo, finish_commit, &finish_root, NULL, NULL, error))
+ return NULL;
+
+ if (!ostree_diff_dirs (OSTREE_DIFF_FLAGS_NONE,
+ init_root,
+ finish_root,
+ modified,
+ removed,
+ added,
+ NULL, error))
+ return NULL;
+
+ for (i = 0; i < added->len; i++)
+ {
+ char *path = g_file_get_relative_path (finish_root, g_ptr_array_index (added, i));
+ g_ptr_array_add (all_paths, path);
+ }
+
+ for (i = 0; i < modified->len; i++)
+ {
+ OstreeDiffItem *modified_item = g_ptr_array_index (modified, i);
+ char *path = g_file_get_relative_path (finish_root, modified_item->target);
+ g_ptr_array_add (all_paths, path);
+ }
+
+ return g_steal_pointer (&all_paths);
+}
+
+GPtrArray *
+builder_cache_get_changes (BuilderCache *self,
+ GError **error)
+{
+ g_autoptr(GPtrArray) added = g_ptr_array_new_with_free_func (g_object_unref);
+ g_autoptr(GPtrArray) modified = g_ptr_array_new_with_free_func ((GDestroyNotify)ostree_diff_item_unref);
+ g_autoptr(GPtrArray) removed = g_ptr_array_new_with_free_func (g_object_unref);
+ g_autoptr(GPtrArray) changed_paths = g_ptr_array_new_with_free_func (g_free);
g_autoptr(GFile) current_root = NULL;
g_autoptr(GFile) parent_root = NULL;
g_autoptr(GVariant) variant = NULL;
@@ -532,10 +585,17 @@ builder_cache_get_changes (BuilderCache *self,
for (i = 0; i < added->len; i++)
{
char *path = g_file_get_relative_path (current_root, g_ptr_array_index (added, i));
- g_ptr_array_add (added_paths, path);
+ g_ptr_array_add (changed_paths, path);
+ }
+
+ for (i = 0; i < modified->len; i++)
+ {
+ OstreeDiffItem *modified_item = g_ptr_array_index (modified, i);
+ char *path = g_file_get_relative_path (current_root, modified_item->target);
+ g_ptr_array_add (changed_paths, path);
}
- return g_steal_pointer (&added_paths);
+ return g_steal_pointer (&changed_paths);
}
void