Skip to content

Commit

Permalink
More testing or stable indexing and updates
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
theory committed Feb 15, 2024
1 parent d2cb6b7 commit d4b4f48
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
10 changes: 8 additions & 2 deletions Changes
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
15 changes: 10 additions & 5 deletions lib/PGXN/API/Indexer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -1347,7 +1352,7 @@ C<merge_distmeta()>.
Iterates over the list of extensions under the C<provides> 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<add_distribution()>, by which this
method is called internally.
Expand Down
31 changes: 22 additions & 9 deletions t/indexer.t
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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} = {
Expand Down

0 comments on commit d4b4f48

Please sign in to comment.