Skip to content

Commit

Permalink
bin/status: Inline metadata parsing for versions
Browse files Browse the repository at this point in the history
Pull out the commit metadata explicitly; still just rendering the version, but
this is prep for rendering other metadata keys.
  • Loading branch information
cgwalters committed Oct 20, 2017
1 parent 7fc3527 commit 154ef57
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/ostree/ot-admin-builtin-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ static GOptionEntry options[] = {
{ NULL }
};

static char *
version_of_commit (OstreeRepo *repo, const char *checksum)
{
g_autoptr(GVariant) variant = NULL;
/* Shouldn't fail, but if it does, we ignore it */
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum,
&variant, NULL))
return NULL;

return ot_admin_checksum_version (variant);
}

static gboolean
deployment_get_gpg_verify (OstreeDeployment *deployment,
OstreeRepo *repo)
Expand Down Expand Up @@ -114,7 +102,20 @@ ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocat
{
OstreeDeployment *deployment = deployments->pdata[i];
const char *ref = ostree_deployment_get_csum (deployment);
g_autofree char *version = version_of_commit (repo, ref);

/* Load the backing commit; shouldn't normally fail, but if it does,
* we stumble on.
*/
g_autoptr(GVariant) commit = NULL;
(void)ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, ref,
&commit, NULL);
g_autoptr(GVariant) commit_metadata = NULL;
if (commit)
commit_metadata = g_variant_get_child_value (commit, 0);

const char *version = NULL;
if (commit_metadata)
(void) g_variant_lookup (commit_metadata, OSTREE_COMMIT_META_KEY_VERSION, "&s", &version);

GKeyFile *origin = ostree_deployment_get_origin (deployment);

Expand Down

0 comments on commit 154ef57

Please sign in to comment.