cmdline/pull: Print final status even if noninteractive
Previously, `ostree pull` was silent if not on a tty. I don't see a reason not to print the final status line at least. This is prep for more work in the test suite, so I can write assertions on the output. But it should also be nicer for people who e.g. do an `ostree pull` in a Jenkins job or whatever. Closes: #981 Approved by: jlebon
This commit is contained in:
parent
90e0d56332
commit
1a9a473580
|
|
@ -125,6 +125,13 @@ dry_run_console_progress_changed (OstreeAsyncProgress *progress,
|
||||||
g_print ("%s\n", buf->str);
|
g_print ("%s\n", buf->str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
noninteractive_console_progress_changed (OstreeAsyncProgress *progress,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
/* We do nothing here - we just want the final status */
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **error)
|
ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||||
{
|
{
|
||||||
|
|
@ -302,6 +309,8 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
|
||||||
{
|
{
|
||||||
if (console.is_tty)
|
if (console.is_tty)
|
||||||
progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console);
|
progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console);
|
||||||
|
else
|
||||||
|
progress = ostree_async_progress_new_and_connect (noninteractive_console_progress_changed, &console);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -321,8 +330,15 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
|
||||||
progress, cancellable, error))
|
progress, cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (progress)
|
if (!console.is_tty && !opt_dry_run)
|
||||||
ostree_async_progress_finish (progress);
|
{
|
||||||
|
g_assert (progress);
|
||||||
|
const char *status = ostree_async_progress_get_status (progress);
|
||||||
|
if (status)
|
||||||
|
g_print ("%s\n", status);
|
||||||
|
}
|
||||||
|
|
||||||
|
ostree_async_progress_finish (progress);
|
||||||
|
|
||||||
if (opt_dry_run)
|
if (opt_dry_run)
|
||||||
g_assert (printed_console_progress);
|
g_assert (printed_console_progress);
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,10 @@ echo "1..25"
|
||||||
|
|
||||||
# Try both syntaxes
|
# Try both syntaxes
|
||||||
repo_init --no-gpg-verify
|
repo_init --no-gpg-verify
|
||||||
${CMD_PREFIX} ostree --repo=repo pull origin main
|
${CMD_PREFIX} ostree --repo=repo pull origin main >out.txt
|
||||||
${CMD_PREFIX} ostree --repo=repo pull origin:main
|
assert_file_has_content out.txt "[1-9][0-9]* metadata, [1-9][0-9]* content objects fetched"
|
||||||
|
${CMD_PREFIX} ostree --repo=repo pull origin:main > out.txt
|
||||||
|
assert_not_file_has_content out.txt "content objects fetched"
|
||||||
${CMD_PREFIX} ostree --repo=repo fsck
|
${CMD_PREFIX} ostree --repo=repo fsck
|
||||||
echo "ok pull"
|
echo "ok pull"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue