mirror of
https://github.com/flatpak/flatpak.git
synced 2026-01-26 14:13:26 +00:00
history: Fix printing refs
The history command seems to have been broken since it was changed to use FlatpakDecomposed, since that type only works for app or runtime refs, resulting in errors such as: $ flatpak history error: appstream2/x86_64 is not application or runtime Fix this by making the logic a bit smarter, and don't let any one invalid ref entry prevent the whole command from working. Fixes #4332 (cherry picked from commit e44b54856e98fb080ded77159979ddd6022981f2)
This commit is contained in:
parent
1810377649
commit
4b37f88c68
@ -217,35 +217,43 @@ print_history (GPtrArray *dirs,
|
||||
strcmp (columns[k].name, "arch") == 0 ||
|
||||
strcmp (columns[k].name, "branch") == 0)
|
||||
{
|
||||
g_autoptr(FlatpakDecomposed) ref = NULL;
|
||||
g_autofree char *ref_str = get_field (j, "REF", error);
|
||||
g_autofree char *ref_str = NULL;
|
||||
g_autofree char *value = NULL;
|
||||
|
||||
ref_str = get_field (j, "REF", error);
|
||||
if (*error)
|
||||
return FALSE;
|
||||
|
||||
if (ref_str && ref_str[0])
|
||||
{
|
||||
ref = flatpak_decomposed_new_from_ref (ref_str, error);
|
||||
if (ref == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
if (ref_str && ref_str[0] &&
|
||||
!is_flatpak_ref (ref_str) &&
|
||||
g_strcmp0 (ref_str, OSTREE_REPO_METADATA_REF) != 0)
|
||||
g_warning ("Unknown ref in history: %s", ref_str);
|
||||
|
||||
if (strcmp (columns[k].name, "ref") == 0)
|
||||
flatpak_table_printer_add_column (printer, ref_str);
|
||||
else
|
||||
value = g_strdup (ref_str);
|
||||
else if (strcmp (columns[k].name, "arch") == 0)
|
||||
{
|
||||
g_autofree char *value = NULL;
|
||||
if (ref)
|
||||
if (ref_str != NULL)
|
||||
value = flatpak_get_arch_for_ref (ref_str);
|
||||
}
|
||||
else if (ref_str && ref_str[0] &&
|
||||
(g_str_has_prefix (ref_str, "app/") ||
|
||||
g_str_has_prefix (ref_str, "runtime/")))
|
||||
{
|
||||
g_autoptr(FlatpakDecomposed) ref = NULL;
|
||||
ref = flatpak_decomposed_new_from_ref (ref_str, NULL);
|
||||
if (ref == NULL)
|
||||
g_warning ("Invalid ref in history: %s", ref_str);
|
||||
else
|
||||
{
|
||||
if (strcmp (columns[k].name, "application") == 0)
|
||||
value = flatpak_decomposed_dup_id (ref);
|
||||
else if (strcmp (columns[k].name, "arch") == 0)
|
||||
value = flatpak_decomposed_dup_arch (ref);
|
||||
else
|
||||
value = flatpak_decomposed_dup_branch (ref);
|
||||
}
|
||||
|
||||
flatpak_table_printer_add_column (printer, value);
|
||||
}
|
||||
|
||||
flatpak_table_printer_add_column (printer, value);
|
||||
}
|
||||
else if (strcmp (columns[k].name, "installation") == 0)
|
||||
{
|
||||
|
||||
@ -43,6 +43,7 @@ char * flatpak_make_valid_id_prefix (const char *orig_id);
|
||||
gboolean flatpak_id_has_subref_suffix (const char *id,
|
||||
gssize id_len);
|
||||
|
||||
gboolean is_flatpak_ref (const char *ref);
|
||||
char * flatpak_get_arch_for_ref (const char *ref);
|
||||
const char *flatpak_get_compat_arch_reverse (const char *compat_arch);
|
||||
|
||||
|
||||
@ -3169,7 +3169,7 @@ flatpak_repo_save_digested_summary_delta (OstreeRepo *repo,
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gboolean
|
||||
is_flatpak_ref (const char *ref)
|
||||
{
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user