From d4b4f487440aead0b87a59fed3edb29943600d7f Mon Sep 17 00:00:00 2001 From: "David E. Wheeler" Date: Thu, 15 Feb 2024 13:51:24 -0500 Subject: [PATCH] More testing or stable indexing and updates Be sure to use the testing abstract and version for extension indexing information when there is no stable version, or the unstable data when there is no testing. Also prevents passing undefined values to the Lucy::Index::Indexer. Similarly, update a user's JSON information with a testing release when there is no stable release, or the unstable release when no testing. This way the most recent release is always associated with the user, rather than no release when there are no existing stable releases! --- Changes | 10 ++++++++-- lib/PGXN/API/Indexer.pm | 15 ++++++++++----- t/indexer.t | 31 ++++++++++++++++++++++--------- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/Changes b/Changes index d568d02..356df77 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,12 @@ Revision history for Perl extension PGXN::API 0.20.1 + - Fixed a bug where a testing extension's version and abstract was not + properly indexed when there was no stable extension (and also unstable + would not be indexed if there was no testing). + - Fixed a bug where a user's JSON file was not updated for a testing + release when there were no previous stable releases, or for an unstable + release when there wer not previous testing releases. 0.20.0 2024-02-09T17:36:10Z - Removed the `Capfile` and `eg` directory. Examples for managing PGXN @@ -15,8 +21,8 @@ Revision history for Perl extension PGXN::API specified via the `docfile` key in its `provides` object, even if it's a README (#10). - The indexer will now index a testing release if there are no stable - releases, and will index an unstable release if there are neither stable - nor testing releases (#2). + releases, and will index an unstable release if there are neither + stable nor testing releases (#2). - Updated the SemVer regex when parsing rsync output to the official version published in https://regex101.com/r/vkijKf/ (#16). - Fix unzipping of distributions to ensure that all directories are diff --git a/lib/PGXN/API/Indexer.pm b/lib/PGXN/API/Indexer.pm index fdf00b1..471bdbe 100644 --- a/lib/PGXN/API/Indexer.pm +++ b/lib/PGXN/API/Indexer.pm @@ -303,7 +303,7 @@ sub merge_distmeta { $api->write_json_to($dist_file => $meta); } - # Index it if it's a new stable release. + # Index it. $self->_index(dists => { key => lc $meta->{name}, dist => $meta->{name}, @@ -359,7 +359,7 @@ sub update_user { my ($self, $p) = @_; say " Updating user $p->{meta}{user}" if $self->verbose; my $user = $self->_update_releases(user => $p->{meta}); - $self->_index_user($user) if $p->{meta}->{release_status} eq 'stable'; + $self->_index_user($user); return $self; } @@ -447,15 +447,20 @@ sub update_extensions { delete $ddvers->{$v} unless $mir_vers->{$v}; } + # Only index testing if no stable, and unstable if no testing. + my $release = $mir_meta->{stable} + || $mir_meta->{testing} + || $mir_meta->{unstable}; + # Write it back out and index it. $api->write_json_to($doc_file => $mir_meta); $self->_index(extensions => { key => lc $mir_meta->{extension}, extension => $mir_meta->{extension}, - abstract => $mir_meta->{stable}{abstract} || '', + abstract => $release->{abstract} || '', docpath => $data->{docpath} || '', dist => $meta->{name}, - version => $mir_meta->{stable}{version}, + version => $release->{version}, date => $meta->{date}, user_name => $self->_get_user_name($meta), user => $meta->{user}, @@ -1347,7 +1352,7 @@ C. Iterates over the list of extensions under the C key in the metadata and updates their respective metadata files (as specified by the "extension" -URI template) and updates them with additional information.The supported +URI template) and updates them with additional information. The supported parameters are the same as those for C, by which this method is called internally. diff --git a/t/indexer.t b/t/indexer.t index 3229057..f9288c9 100644 --- a/t/indexer.t +++ b/t/indexer.t @@ -341,8 +341,12 @@ is_deeply $doc_data, $mir_data, fcopy catfile(qw(t data theory-updated.json)), catfile($api->mirror_root, qw(user theory.json)); $params->{meta} = $meta_011; -ok $indexer->update_user($params), - 'Update the user metadata for pair 0.1.1'; +{ + # Tell it not to index. + local $indexer->{_index_it} = 0; + ok $indexer->update_user($params), + 'Update the user metadata for pair 0.1.1'; +} is_deeply $indexer->to_index->{users}, [], 'Should have no index update for test dist'; @@ -604,15 +608,24 @@ is_deeply $doc_data, $exp, fcopy catfile(qw(t data pair-ext-updated.json)), catfile($api->mirror_root, qw(extension pair.json)); $params->{meta} = $meta_011; -do { - # Tell it not to index. - local $indexer->{_index_it} = 0; ok $indexer->update_extensions($params), 'Update the extension metadata to 0.1.1'; -}; -is_deeply $indexer->to_index, { - map { $_ => [] } qw(docs dists extensions users tags) -}, 'Should have no indexed extensions with _index_it false'; + +# It should have indexed the testing release because there is no existin stable +# release. Normally would not happen when there is an existing stable version +# because merge_distmeta, called by add_distribution, would have set _index_it +# to false. This test ensures that it indexes the highest status relaese. +is_deeply shift @{ $indexer->to_index->{extensions} }, { + abstract => 'A key/value pair data type', + date => '2010-10-29T22:46:45Z', + dist => 'pair', + docpath => 'docs/howto', + extension => 'pair', + key => 'pair', + user => 'theory', + user_name => 'David E. Wheeler', + version => '0.1.0', +}, 'Should have stable extension index data'; $exp->{latest} = 'testing'; $exp->{testing} = {