Skip to content

Commit

Permalink
Add a --title option to repo-update
Browse files Browse the repository at this point in the history
This stores a human-readable title in the additional metadata
of the repo summary. We use xa.title as the key.
  • Loading branch information
Matthias Clasen committed Feb 9, 2015
1 parent 2054f0e commit 34dda64
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
8 changes: 6 additions & 2 deletions completion/xdg-app
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ _xdg-app() {
[BUILD]='--runtime --network --x11'
[BUILD_FINISH]='--command --allow'
[BUILD_EXPORT]='--subject --body'
[ARG]='--arch --command --branch --var --allow --forbid --subject --body --runtime'
[REPO_UPDATE]='--title'
[ARG]='--arch --command --branch --var --allow --forbid --subject --body --title --runtime'
)

if __contains_word "--user" ${COMP_WORDS[*]}; then
Expand All @@ -56,7 +57,7 @@ _xdg-app() {
--allow|--forbid)
comps='x11 wayland ipc pulseaudio system-dbus session-dbus network host-fs homedir'
;;
--branch|--subject|--body)
--branch|--subject|--body|--title)
comps=''
;;
esac
Expand Down Expand Up @@ -152,6 +153,9 @@ _xdg-app() {
if [ "$verb" = "build-export" ]; then
comps="$comps ${OPTS[BUILD_EXPORT]}"
fi
if [ "$verb" = "repo-update" ]; then
comps="$comps ${OPTS[REPO_UPDATE]}"
fi

else
case "$verb" in
Expand Down
9 changes: 9 additions & 0 deletions doc/xdg-app-repo-update.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@
</para></listitem>
</varlistentry>

<varlistentry>
<term><option>--title=TITLE</option></term>

<listitem><para>
A title for the repository, e.g. for display in a UI.
The title is stored in the repository summary.
</para></listitem>
</varlistentry>

<varlistentry>
<term><option>-v</option></term>
<term><option>--verbose</option></term>
Expand Down
21 changes: 19 additions & 2 deletions xdg-app-builtins-repo-update.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"

static char *opt_title;

static GOptionEntry options[] = {
{ "title", 0, 0, G_OPTION_ARG_STRING, &opt_title, "A nice name to use for this repository", "TITLE" },
{ NULL }
};


gboolean
xdg_app_builtin_repo_update (int argc, char **argv, GCancellable *cancellable, GError **error)
Expand All @@ -19,10 +26,11 @@ xdg_app_builtin_repo_update (int argc, char **argv, GCancellable *cancellable, G
gs_unref_object GFile *repofile = NULL;
gs_unref_object OstreeRepo *repo = NULL;
const char *location;
GVariant *extra = NULL;

context = g_option_context_new ("LOCATION - Update repository metadata");

if (!xdg_app_option_context_parse (context, NULL, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
if (!xdg_app_option_context_parse (context, options, &argc, &argv, XDG_APP_BUILTIN_FLAG_NO_DIR, NULL, cancellable, error))
goto out;

if (argc < 2)
Expand All @@ -39,7 +47,16 @@ xdg_app_builtin_repo_update (int argc, char **argv, GCancellable *cancellable, G
if (!ostree_repo_open (repo, cancellable, error))
goto out;

if (!ostree_repo_regenerate_summary (repo, NULL, cancellable, error))
if (opt_title)
{
GVariantBuilder builder;

g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add (&builder, "{sv}", "xa.title", g_variant_new_string (opt_title));
extra = g_variant_builder_end (&builder);
}

if (!ostree_repo_regenerate_summary (repo, extra, cancellable, error))
goto out;

/* TODO: appstream data */
Expand Down

0 comments on commit 34dda64

Please sign in to comment.