-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli: Add "get-latest-version" util command #503
base: main
Are you sure you want to change the base?
Conversation
Fixes: 3f88c4e ("Add new is-satisfied check to test relations from the command-line")
This gets the latest version specified in an appdata file, which, combined with utilities such as check-news.sh[1], can be used to check whether the date specified in the appdata's release information is correct. See https://gitlab.gnome.org/GNOME/evince/-/issues/1950 Closes: ximion#502 [1]: https://gitlab.gnome.org/GNOME/totem/-/blob/master/check-news.sh
8d4b43c
to
4e8120a
Compare
Instead of appstream-util, as it is in deep maintenance mode. See: ximion/appstream#503
_("Check if requirements of a component (via its ID or MetaInfo file) are satisfied on this system."), | ||
as_client_run_is_satisfied); | ||
ascli_add_cmd (commands, | ||
2, "get-latest-version", NULL, "FILE", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should be called metainfo-latest-version
or something, to make clear we're not querying the latest AppStream version... But the confusion potential is probably not that high...
ascli_add_cmd (commands, | ||
2, "get-latest-version", NULL, "FILE", | ||
/* TRANSLATORS: `appstreamcli get-latest-version command description. */ | ||
_("Get the latest version from the AppData file"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_("Get the latest version from the AppData file"), | |
_("Get the latest version from the MetaInfo file"), |
(the file format is called MetaInfo, AppData is an ancient name from an early draft)
(g_str_has_suffix (fname, ".yml")) || | ||
(g_str_has_suffix (fname, ".yaml"))) { | ||
/* if we have YAML, we also automatically assume a catalog style */ | ||
as_metadata_set_format_style (metad, AS_FORMAT_STYLE_CATALOG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make any sense to read this for CATALOG
data? Since catalog files contain many components, you would currently just get a random version, so I don't think that makes sense.
I think it would be better if this code would just error-out in that case and limit itself to metainfo files.
The added benefit of that would be that this code would be much smaller then too ;-)
for (guint i = 0; i < releases->len; i++) { | ||
AsRelease *release_tmp = g_ptr_array_index (releases, i); | ||
if (release_newest == NULL || | ||
as_release_get_timestamp (release_tmp) > as_release_get_timestamp (release_newest)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may not always have a timestamp (e.g. for development versions / unreleased ones).
Since the release
entries must be sorted highest to lowest, we could cheat here and just pick the first release entry, or we could go the extra mile of comparing version numbers if one of the releases has no timestamp...
Is it common that there are sorting errors with release
elements? (appstreamcli validate
should throw an error for that).
return 3; | ||
} | ||
|
||
cpt = g_object_ref (as_metadata_get_component (metad)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: You don't need to reference the AsComponent here, as it is held for the duration of AsMetadata's life. That said, it also doesn't really hurt either.
This gets the latest version specified in an appdata file, which,
combined with utilities such as check-news.sh1, can be used to check
whether the date specified in the appdata's release information is
correct.
See https://gitlab.gnome.org/GNOME/evince/-/issues/1950
Closes: #502