forked from Mirrors/flatpak-builder
Make add-remote use title from summary
When we add a remote, load the summary from the repository, and use the title if there is one. This at the same time serves as (minimal) validation of the repository url.tingping/wmclass
parent
34dda64b95
commit
1e69e3fc42
|
@ -7,6 +7,7 @@
|
|||
#include "libgsystem.h"
|
||||
|
||||
#include "xdg-app-builtins.h"
|
||||
#include "xdg-app-utils.h"
|
||||
|
||||
static gboolean opt_no_gpg_verify;
|
||||
static gboolean opt_if_not_exists;
|
||||
|
@ -26,6 +27,8 @@ xdg_app_builtin_add_remote (int argc, char **argv, GCancellable *cancellable, GE
|
|||
gboolean ret = FALSE;
|
||||
gs_unref_object XdgAppDir *dir = NULL;
|
||||
gs_unref_variant_builder GVariantBuilder *optbuilder = NULL;
|
||||
gs_unref_hashtable GHashTable *refs = NULL;
|
||||
gs_free char *title = NULL;
|
||||
const char *remote_name;
|
||||
const char *remote_url;
|
||||
|
||||
|
@ -45,14 +48,24 @@ xdg_app_builtin_add_remote (int argc, char **argv, GCancellable *cancellable, GE
|
|||
|
||||
optbuilder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
|
||||
|
||||
if (!ostree_repo_load_summary (remote_url, &refs, &title, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (opt_no_gpg_verify)
|
||||
g_variant_builder_add (optbuilder, "{s@v}",
|
||||
"gpg-verify",
|
||||
g_variant_new_variant (g_variant_new_boolean (FALSE)));
|
||||
|
||||
if (opt_title)
|
||||
{
|
||||
g_free (title);
|
||||
title = g_strdup (opt_title);
|
||||
}
|
||||
|
||||
if (title)
|
||||
g_variant_builder_add (optbuilder, "{s@v}",
|
||||
"xa.title",
|
||||
g_variant_new_variant (g_variant_new_string (opt_title)));
|
||||
g_variant_new_variant (g_variant_new_string (title)));
|
||||
|
||||
if (!ostree_repo_remote_change (xdg_app_dir_get_repo (dir), NULL,
|
||||
opt_if_not_exists ? OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS :
|
||||
|
|
Loading…
Reference in New Issue