forked from Mirrors/flatpak-builder
list/ls-remotes: Use the new remote helpers
parent
5bc44ea125
commit
4cdec26264
|
@ -49,7 +49,7 @@ xdg_app_builtin_list_remotes (int argc, char **argv, GCancellable *cancellable,
|
|||
g_autoptr(XdgAppDir) user_dir = NULL;
|
||||
g_autoptr(XdgAppDir) system_dir = NULL;
|
||||
XdgAppDir *dirs[2] = { 0 };
|
||||
guint ii, n_remotes = 0, n_dirs = 0, j;
|
||||
guint i = 0, n_dirs = 0, j;
|
||||
XdgAppTablePrinter *printer;
|
||||
|
||||
context = g_option_context_new (" - List remote repositories");
|
||||
|
@ -80,30 +80,25 @@ xdg_app_builtin_list_remotes (int argc, char **argv, GCancellable *cancellable,
|
|||
for (j = 0; j < n_dirs; j++)
|
||||
{
|
||||
XdgAppDir *dir = dirs[j];
|
||||
GKeyFile *config;
|
||||
g_auto(GStrv) remotes = NULL;
|
||||
|
||||
if (!xdg_app_dir_ensure_repo (dir, cancellable, NULL))
|
||||
continue;
|
||||
remotes = xdg_app_dir_list_remotes (dir, cancellable, error);
|
||||
if (remotes == NULL)
|
||||
return FALSE;
|
||||
|
||||
config = ostree_repo_get_config (xdg_app_dir_get_repo (dir));
|
||||
remotes = ostree_repo_remote_list (xdg_app_dir_get_repo (dir), &n_remotes);
|
||||
|
||||
for (ii = 0; ii < n_remotes; ii++)
|
||||
for (i = 0; remotes[i] != NULL; i++)
|
||||
{
|
||||
char *remote_name = remotes[i];
|
||||
|
||||
if (opt_show_details)
|
||||
{
|
||||
char *remote_name = remotes[ii];
|
||||
g_autofree char *remote_url = NULL;
|
||||
g_autofree char *group = NULL;
|
||||
g_autofree char *title = NULL;
|
||||
gboolean gpg_verify = TRUE;
|
||||
|
||||
group = g_strdup_printf ("remote \"%s\"", remote_name);
|
||||
|
||||
xdg_app_table_printer_add_column (printer, remote_name);
|
||||
|
||||
title = g_key_file_get_string (config, group, "xa.title", NULL);
|
||||
title = xdg_app_dir_get_remote_title (dir, remote_name);
|
||||
if (title)
|
||||
xdg_app_table_printer_add_column (printer, title);
|
||||
else
|
||||
|
@ -124,7 +119,7 @@ xdg_app_builtin_list_remotes (int argc, char **argv, GCancellable *cancellable,
|
|||
xdg_app_table_printer_append_with_comma (printer, dir == user_dir ? "user" : "system");
|
||||
}
|
||||
else
|
||||
xdg_app_table_printer_add_column (printer, remotes[ii]);
|
||||
xdg_app_table_printer_add_column (printer, remote_name);
|
||||
|
||||
xdg_app_table_printer_finish_row (printer);
|
||||
}
|
||||
|
|
|
@ -49,9 +49,7 @@ xdg_app_builtin_ls_remote (int argc, char **argv, GCancellable *cancellable, GEr
|
|||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(XdgAppDir) dir = NULL;
|
||||
OstreeRepo *repo = NULL;
|
||||
g_autoptr(GHashTable) refs = NULL;
|
||||
g_autofree char *title = NULL;
|
||||
GHashTableIter iter;
|
||||
gpointer key;
|
||||
gpointer value;
|
||||
|
@ -70,11 +68,11 @@ xdg_app_builtin_ls_remote (int argc, char **argv, GCancellable *cancellable, GEr
|
|||
|
||||
repository = argv[1];
|
||||
|
||||
repo = xdg_app_dir_get_repo (dir);
|
||||
if (!ostree_repo_remote_get_url (repo, repository, &url, error))
|
||||
return FALSE;
|
||||
|
||||
if (!ostree_repo_load_summary (url, &refs, &title, cancellable, error))
|
||||
if (!xdg_app_dir_list_remote_refs (dir,
|
||||
repository,
|
||||
&refs,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
names = g_ptr_array_new_with_free_func (g_free);
|
||||
|
@ -131,19 +129,19 @@ xdg_app_builtin_ls_remote (int argc, char **argv, GCancellable *cancellable, GEr
|
|||
|
||||
if (name)
|
||||
{
|
||||
gboolean found = FALSE;
|
||||
gboolean found = FALSE;
|
||||
|
||||
for (i = 0; i < names->len; i++)
|
||||
{
|
||||
if (strcmp (name, g_ptr_array_index (names, i)) == 0)
|
||||
found = TRUE;
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
if (!found)
|
||||
g_ptr_array_add (names, name);
|
||||
else
|
||||
g_free (name);
|
||||
else
|
||||
g_free (name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue