Add "ostree remote list" command
Lists available remote names.
This commit is contained in:
parent
39be27fc93
commit
e54d48be39
|
|
@ -49,7 +49,7 @@ Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
<refsynopsisdiv>
|
<refsynopsisdiv>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>ostree remote</command> <arg choice="opt" rep="repeat">OPTIONS</arg> add <arg choice="req">NAME</arg> <arg choice="req">URL</arg> <arg choice="opt" rep="repeat">BRANCH</arg>
|
<command>ostree remote add</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="req">NAME</arg> <arg choice="req">URL</arg> <arg choice="opt" rep="repeat">BRANCH</arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>ostree remote delete</command> <arg choice="req">NAME</arg>
|
<command>ostree remote delete</command> <arg choice="req">NAME</arg>
|
||||||
|
|
@ -57,6 +57,9 @@ Boston, MA 02111-1307, USA.
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>ostree remote show-url</command> <arg choice="req">NAME</arg>
|
<command>ostree remote show-url</command> <arg choice="req">NAME</arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
|
<cmdsynopsis>
|
||||||
|
<command>ostree remote list</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="req">NAME</arg>
|
||||||
|
</cmdsynopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
|
|
@ -68,7 +71,7 @@ Boston, MA 02111-1307, USA.
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title>Options</title>
|
<title>'Add' Options</title>
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
|
@ -89,6 +92,20 @@ Boston, MA 02111-1307, USA.
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>'List' Options</title>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-u, --show-urls</option></term>
|
||||||
|
|
||||||
|
<listitem><para>
|
||||||
|
Show remote URLs in list
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title>Example</title>
|
<title>Example</title>
|
||||||
<para><command>$ ostree remote show-url local</command></para>
|
<para><command>$ ostree remote show-url local</command></para>
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,61 @@ ostree_remote_builtin_show_url (int argc, char **argv, GCancellable *cancellable
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean opt_show_urls;
|
||||||
|
|
||||||
|
static GOptionEntry list_option_entries[] = {
|
||||||
|
{ "show-urls", 'u', 0, G_OPTION_ARG_NONE, &opt_show_urls, "Show remote URLs in list", NULL },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
ostree_remote_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||||
|
{
|
||||||
|
GOptionContext *context;
|
||||||
|
gs_unref_object OstreeRepo *repo = NULL;
|
||||||
|
gs_strfreev char **remotes = NULL;
|
||||||
|
guint ii, n_remotes = 0;
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
|
context = g_option_context_new ("- List remote repository names");
|
||||||
|
|
||||||
|
if (!ostree_option_context_parse (context, list_option_entries, &argc, &argv,
|
||||||
|
OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
remotes = ostree_repo_remote_list (repo, &n_remotes);
|
||||||
|
|
||||||
|
if (opt_show_urls)
|
||||||
|
{
|
||||||
|
int max_length = 0;
|
||||||
|
|
||||||
|
for (ii = 0; ii < n_remotes; ii++)
|
||||||
|
max_length = MAX (max_length, strlen (remotes[ii]));
|
||||||
|
|
||||||
|
for (ii = 0; ii < n_remotes; ii++)
|
||||||
|
{
|
||||||
|
gs_free char *remote_url = NULL;
|
||||||
|
|
||||||
|
if (!ostree_repo_remote_get_url (repo, remotes[ii], &remote_url, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
g_print ("%-*s %s\n", max_length, remotes[ii], remote_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (ii = 0; ii < n_remotes; ii++)
|
||||||
|
g_print ("%s\n", remotes[ii]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = TRUE;
|
||||||
|
|
||||||
|
out:
|
||||||
|
g_option_context_free (context);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error);
|
gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error);
|
||||||
|
|
@ -230,6 +285,7 @@ static OstreeRemoteCommand remote_subcommands[] = {
|
||||||
{ "add", ostree_remote_builtin_add },
|
{ "add", ostree_remote_builtin_add },
|
||||||
{ "delete", ostree_remote_builtin_delete },
|
{ "delete", ostree_remote_builtin_delete },
|
||||||
{ "show-url", ostree_remote_builtin_show_url },
|
{ "show-url", ostree_remote_builtin_show_url },
|
||||||
|
{ "list", ostree_remote_builtin_list },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,24 @@ $OSTREE remote add --if-not-exists --no-gpg-verify another-noexist http://anothe
|
||||||
$OSTREE remote show-url another-noexist >/dev/null
|
$OSTREE remote show-url another-noexist >/dev/null
|
||||||
echo "ok"
|
echo "ok"
|
||||||
|
|
||||||
|
$OSTREE remote list > list.txt
|
||||||
|
assert_file_has_content list.txt "origin"
|
||||||
|
assert_file_has_content list.txt "another"
|
||||||
|
assert_file_has_content list.txt "another-noexist"
|
||||||
|
assert_not_file_has_content list.txt "http://example.com/ostree/gnome"
|
||||||
|
assert_not_file_has_content list.txt "http://another.com/repo"
|
||||||
|
assert_not_file_has_content list.txt "http://another-noexist.example.com/anotherrepo"
|
||||||
|
echo "ok remote list"
|
||||||
|
|
||||||
|
$OSTREE remote list --show-urls > list.txt
|
||||||
|
assert_file_has_content list.txt "origin"
|
||||||
|
assert_file_has_content list.txt "another"
|
||||||
|
assert_file_has_content list.txt "another-noexist"
|
||||||
|
assert_file_has_content list.txt "http://example.com/ostree/gnome"
|
||||||
|
assert_file_has_content list.txt "http://another.com/repo"
|
||||||
|
assert_file_has_content list.txt "http://another-noexist.example.com/anotherrepo"
|
||||||
|
echo "ok remote list with urls"
|
||||||
|
|
||||||
$OSTREE remote delete another
|
$OSTREE remote delete another
|
||||||
echo "ok remote delete"
|
echo "ok remote delete"
|
||||||
|
|
||||||
|
|
@ -68,3 +86,10 @@ if $OSTREE remote show-url origin 2>/dev/null; then
|
||||||
assert_not_reached "Deleting remote unexpectedly failed"
|
assert_not_reached "Deleting remote unexpectedly failed"
|
||||||
fi
|
fi
|
||||||
echo "ok"
|
echo "ok"
|
||||||
|
|
||||||
|
$OSTREE remote list > list.txt
|
||||||
|
assert_not_file_has_content list.txt "origin"
|
||||||
|
# Can't grep for 'another' because of 'another-noexist'
|
||||||
|
assert_file_has_content list.txt "another-noexist"
|
||||||
|
echo "ok remote list remaining"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue