From a180a35a4844302336a53788422437e770e07c9f Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 20 Apr 2017 21:51:35 -0400 Subject: [PATCH] status: Do show Commit with --verbose, don't show StateRoot without it `Commit` is useful in cases where one wants to e.g. run `rpm-ostree db diff`. `StateRoot` however is going to be in the vast majority of cases identical across deployments. Closes: #743 Approved by: jlebon --- src/app/rpmostree-builtin-status.c | 7 +++++-- tests/check/test-basic.sh | 9 ++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/rpmostree-builtin-status.c b/src/app/rpmostree-builtin-status.c index a9f395aa..ad3933d0 100644 --- a/src/app/rpmostree-builtin-status.c +++ b/src/app/rpmostree-builtin-status.c @@ -35,10 +35,12 @@ #include static gboolean opt_pretty; +static gboolean opt_verbose; static gboolean opt_json; static GOptionEntry option_entries[] = { { "pretty", 'p', 0, G_OPTION_ARG_NONE, &opt_pretty, "This option is deprecated and no longer has any effect", NULL }, + { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Print additional fields (e.g. StateRoot)", NULL }, { "json", 0, 0, G_OPTION_ARG_NONE, &opt_json, "Output JSON", NULL }, { NULL } }; @@ -267,7 +269,7 @@ status_generic (RPMOSTreeSysroot *sysroot_proxy, if (is_locally_assembled) print_kv ("BaseCommit", max_key_len, base_checksum); - else + if (opt_verbose || !is_locally_assembled) print_kv ("Commit", max_key_len, checksum); /* Show any difference between the baseref vs head, but only for the @@ -304,7 +306,8 @@ status_generic (RPMOSTreeSysroot *sysroot_proxy, } /* This used to be OSName; see https://github.com/ostreedev/ostree/pull/794 */ - print_kv ("StateRoot", max_key_len, os_name); + if (opt_verbose) + print_kv ("StateRoot", max_key_len, os_name); if (!g_variant_dict_lookup (dict, "gpg-enabled", "b", &gpg_enabled)) gpg_enabled = FALSE; diff --git a/tests/check/test-basic.sh b/tests/check/test-basic.sh index 990d0430..cdd5d590 100755 --- a/tests/check/test-basic.sh +++ b/tests/check/test-basic.sh @@ -24,7 +24,7 @@ export RPMOSTREE_SUPPRESS_REQUIRES_ROOT_CHECK=yes ensure_dbus -echo "1..18" +echo "1..19" setup_os_repository "archive-z2" "syslinux" @@ -49,6 +49,13 @@ ostree admin --sysroot=sysroot deploy --karg=root=LABEL=MOO --karg=quiet --os=te assert_status_jq '.deployments[0].version == "1.0.10"' echo "ok status shows right version" +rpm-ostree status > status.txt +assert_file_has_content status.txt 'Version: 1.0.10' +assert_not_file_has_content status.txt StateRoot: +rpm-ostree status -v > status.txt +assert_file_has_content status.txt StateRoot: +echo "ok status text" + dbus-send --session --dest=org.projectatomic.rpmostree1 --print-reply=literal /org/projectatomic/rpmostree1/testos org.projectatomic.rpmostree1.OSExperimental.Moo boolean:true > moo.txt assert_file_has_content moo.txt '🐄' echo "ok experimental"