repo: Add ostree_repo_remote_get_url()
Peeking at remote details by way of ostree_repo_copy_config() doesn't work anymore.
This commit is contained in:
parent
17b9e399b8
commit
f79896693e
|
|
@ -701,6 +701,47 @@ ostree_repo_remote_delete (OstreeRepo *self,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_repo_remote_get_url:
|
||||
* @self: Repo
|
||||
* @name: Name of remote
|
||||
* @out_url: (out) (allow-none): Remote's URL
|
||||
* @error: Error
|
||||
*
|
||||
* Return the URL of the remote named @name through @out_url. It is an
|
||||
* error if the provided remote does not exist.
|
||||
*
|
||||
* Returns: %TRUE on success, %FALSE on failure
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_remote_get_url (OstreeRepo *self,
|
||||
const char *name,
|
||||
char **out_url,
|
||||
GError **error)
|
||||
{
|
||||
local_cleanup_remote OstreeRemote *remote = NULL;
|
||||
gs_free char *url = NULL;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
|
||||
remote = ost_repo_get_remote (self, name, error);
|
||||
|
||||
if (remote == NULL)
|
||||
goto out;
|
||||
|
||||
url = g_key_file_get_string (remote->options, remote->group, "url", error);
|
||||
|
||||
if (url != NULL)
|
||||
{
|
||||
gs_transfer_out_value (out_url, &url);
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ostree_repo_mode_to_string (OstreeRepoMode mode,
|
||||
const char **out_mode,
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@ gboolean ostree_repo_remote_delete (OstreeRepo *self,
|
|||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
gboolean ostree_repo_remote_get_url (OstreeRepo *self,
|
||||
const char *name,
|
||||
char **out_url,
|
||||
GError **error);
|
||||
|
||||
OstreeRepo * ostree_repo_get_parent (OstreeRepo *self);
|
||||
|
||||
gboolean ostree_repo_write_config (OstreeRepo *self,
|
||||
|
|
|
|||
|
|
@ -71,9 +71,7 @@ ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError
|
|||
gs_unref_object OstreeRepo *repo = NULL;
|
||||
gboolean ret = FALSE;
|
||||
const char *op;
|
||||
gs_free char *key = NULL;
|
||||
guint i;
|
||||
GKeyFile *config = NULL;
|
||||
const char *remote_name;
|
||||
|
||||
context = g_option_context_new ("OPERATION NAME [args] - Control remote repository configuration");
|
||||
|
|
@ -93,9 +91,6 @@ ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError
|
|||
|
||||
op = argv[1];
|
||||
remote_name = argv[2];
|
||||
key = g_strdup_printf ("remote \"%s\"", remote_name);
|
||||
|
||||
config = ostree_repo_copy_config (repo);
|
||||
|
||||
if (!strcmp (op, "add"))
|
||||
{
|
||||
|
|
@ -155,8 +150,7 @@ ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError
|
|||
{
|
||||
gs_free char *url = NULL;
|
||||
|
||||
url = g_key_file_get_string (config, key, "url", error);
|
||||
if (url == NULL)
|
||||
if (!ostree_repo_remote_get_url (repo, remote_name, &url, error))
|
||||
goto out;
|
||||
|
||||
g_print ("%s\n", url);
|
||||
|
|
@ -176,7 +170,5 @@ ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError
|
|||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
if (config)
|
||||
g_key_file_free (config);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue