diff options
author | Dan Nicholson <dbn@endlessos.org> | 2022-02-04 14:11:06 -0700 |
---|---|---|
committer | Dan Nicholson <dbn@endlessos.org> | 2022-02-04 14:28:11 -0700 |
commit | 6fbf759279ca9908e0c7ceb2a3af75b1180fa8a1 (patch) | |
tree | 5fad437182bc276214aeb122776cd89abc28dc45 /src/libostree/ostree-repo.c | |
parent | a588295d3a9adbd98547dc7fc72eabcdfb8541fa (diff) | |
download | ostree-6fbf759279ca9908e0c7ceb2a3af75b1180fa8a1.tar.gz |
lib/repo: Add commit version metadata to summary metadata
The commit metadata `version` key is well established but getting it for
a remote commit is cumbersome since the commit object needs to be
fetched and loaded. Including it in the summary additional metadata
allows a much more convenient view of what each of the remote refs
represents.
Diffstat (limited to 'src/libostree/ostree-repo.c')
-rw-r--r-- | src/libostree/ostree-repo.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index 64a8fea9..6c541029 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -6067,10 +6067,11 @@ summary_add_ref_entry (OstreeRepo *self, g_autoptr(GVariant) commit_obj = NULL; if (!ostree_repo_load_variant (self, OSTREE_OBJECT_TYPE_COMMIT, checksum, &commit_obj, error)) return FALSE; + g_autoptr(GVariant) orig_metadata = g_variant_get_child_value (commit_obj, 0); g_variant_dict_init (&commit_metadata_builder, NULL); - /* Forward the commit’s timestamp if it’s valid. */ + /* Forward the commit’s timestamp and version if they're valid. */ guint64 commit_timestamp = ostree_commit_get_timestamp (commit_obj); g_autoptr(GDateTime) dt = g_date_time_new_from_unix_utc (commit_timestamp); @@ -6078,6 +6079,10 @@ summary_add_ref_entry (OstreeRepo *self, g_variant_dict_insert_value (&commit_metadata_builder, OSTREE_COMMIT_TIMESTAMP, g_variant_new_uint64 (GUINT64_TO_BE (commit_timestamp))); + const char *version = NULL; + if (g_variant_lookup (orig_metadata, OSTREE_COMMIT_META_KEY_VERSION, "&s", &version)) + g_variant_dict_insert (&commit_metadata_builder, OSTREE_COMMIT_VERSION, "s", version); + g_variant_builder_add_value (refs_builder, g_variant_new ("(s(t@ay@a{sv}))", ref, (guint64) g_variant_get_size (commit_obj), |