Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
eecdf00
package indexing: try to avoid partial updates
rjbs Apr 29, 2023
6ec9423
PAUSE::Indexer::Context: a (currently zero-value) object for context
rjbs Apr 29, 2023
2c82b0a
Indexer context: move indexing warnings to context
rjbs Apr 29, 2023
c27e5f0
Indexer context: move alerts to context
rjbs Apr 29, 2023
a0badf2
indexer: make more dist indexing steps check for skip
rjbs Apr 29, 2023
93309d7
indexer: add Abort and Errors to control indexing
rjbs Apr 29, 2023
c86ea5a
indexer: a big refactor to change how we abort indexing
rjbs Apr 30, 2023
fc66040
indexer constants: remove a bunch of dead constants
rjbs Apr 29, 2023
14d78d9
indexer context: call a method instead of copypasting
rjbs Apr 30, 2023
8b9643f
indexer: improve the no_distname_permissions error
rjbs Apr 30, 2023
866401d
indexer: restructure the try/catch for dist indexing
rjbs Apr 30, 2023
97720dc
indexer: drop old warning code, use the new code
rjbs Apr 30, 2023
2bc7dbb
no_index rules: simplify code while refactoring
rjbs Apr 30, 2023
a46c0cc
indexer: turn Abort into Abort::Dist
rjbs Apr 30, 2023
31295bf
indexer: gather packages, then index them
rjbs Apr 30, 2023
fb2e9f7
indexer: introduce an Abort::Package catch loop
rjbs Apr 30, 2023
85bd6bf
indexer: factor our part of the package indexer
rjbs Apr 30, 2023
44ebe76
indexer: try to use "return early" instead of $ok more
rjbs Apr 30, 2023
e3479b9
indexer context: add package-level indexing status
rjbs May 3, 2023
e2a6087
indexer: clean up a weirdly-formatted comment
rjbs May 3, 2023
1cf44f2
indexer: use ->abort_indexing_package
rjbs May 3, 2023
56a6a3e
replace use of index_status with context in reporting
rjbs May 3, 2023
da56d3c
indexer: reintroduce parameters to package-level errors
rjbs May 3, 2023
7486d0b
indexer: improve what we provide as overall status
rjbs May 3, 2023
5c7a581
indexer: word wrap the "nothing updated" text
rjbs May 3, 2023
4f9bb69
PAUSE::Indexer::Errors: make sure Carp is loaded, we use it!
rjbs May 7, 2024
28e0907
PAUSE::Package: pass older_isa_regular_perl along
rjbs May 8, 2024
370e8d5
PAUSE::Indexer::Context: make alert and error methods look the same
rjbs May 8, 2024
52c1207
PAUSE::Indexer::Context: log package errors when setting them
rjbs May 11, 2024
851486c
PAUSE::package: remove dead, commented-out code
rjbs May 11, 2024
b9e0cfd
Mock::Dist: remove this unused code
rjbs May 12, 2024
fdf0b30
PAUSE::Indexer::Errors: fix keys from $old
rjbs Jun 22, 2024
3f6529a
PAUSE::Indexer::Context: make add_dist_error only accept refs
rjbs Jun 22, 2024
2ea7aae
PAUSE::Indexer::Context: pass hashrefs to abort_indexing_dist
rjbs Jun 22, 2024
963b406
PAUSE::dist: do not include private errors in report
rjbs Jun 22, 2024
881c933
PAUSE::DBError: use block-style package
rjbs Jun 22, 2024
aa70f35
PAUSE.pm: move email sending into PAUSE.pm
rjbs Jun 22, 2024
62a6c4a
PAUSE.pm: add "write mail to mbox" facility
rjbs Jun 22, 2024
5ab3bcb
indexer: add tests for "nothing to index" email
rjbs Jun 22, 2024
00dcfea
indexer: be more precise in "nothing to index" email text
rjbs Jun 22, 2024
975c265
PAUSE::pmfile: keep packages that pass all no_index rules
rjbs Oct 11, 2026
8a4a378
PAUSE::package: abort a bad package name with a real package error
rjbs Oct 11, 2026
3ee1a29
indexer: only call ->isa on abort exceptions that are objects
rjbs Oct 11, 2026
79f1a51
indexer: reject distribution_type "script" dists with a report
rjbs Oct 11, 2026
a408700
indexer: don't send failure reports for trial releases
rjbs Oct 11, 2026
7ecfe3a
PAUSE::package: drop dead args to __do_regular_perl_update
rjbs Oct 11, 2026
8d5b000
PAUSE::Indexer::Errors: name the right error when arguments are missing
rjbs Oct 20, 2026
9e5c151
on a very small (or large) version, report it and do not index
rjbs Apr 28, 2023
f08967a
indexer: use JSON::to_json and from_json, not the obsolete names
rjbs Oct 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions lib/PAUSE.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use File::Basename ();
use Compress::Zlib ();
use Cwd ();
use DBI ();
use Email::Sender::Simple ();
use Exporter;
use Fcntl qw(:flock);
my $HAVE_RECENTFILE = eval {require File::Rsync::Mirror::Recentfile; 1;};
Expand Down Expand Up @@ -562,16 +563,38 @@ sub may_overwrite_file {
return;
}

package PAUSE::DBError;
sub sendmail {
my ($self, $email) = @_;

sub new {
my ($class, $msg) = @_;
return bless \$msg, $class;
if ($ENV{PAUSE_TEST_MAIL_MBOX}) {
# This is here for extra testing. If you set this to a filename, every
# email will be written to this mbox. Make sure it's an *absolute* path,
# because the tests change directory. -- rjbs, 2024-06-22

require Email::Sender::Transport::Mbox;
state $mbox = Email::Sender::Transport::Mbox->new({
filename => $ENV{PAUSE_TEST_MAIL_MBOX},
});

$mbox->send_email(Email::Abstract->new($email), {
from => 'test-system',
to => 'test-system',
});
}

Email::Sender::Simple->send($email);
}

use overload (
'""' => sub { ${$_[0]} }
);
package PAUSE::DBError {
sub new {
my ($class, $msg) = @_;
return bless \$msg, $class;
}

use overload (
'""' => sub { ${$_[0]} }
);
}

1;

Expand Down
16 changes: 16 additions & 0 deletions lib/PAUSE/Indexer/Abort/Dist.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package PAUSE::Indexer::Abort::Dist;
use v5.12.0;
use Moo;

has public => (
is => 'ro',
default => 0,
);

has message => (
is => 'ro',
required => 1,
);

no Moo;
1;
16 changes: 16 additions & 0 deletions lib/PAUSE/Indexer/Abort/Package.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package PAUSE::Indexer::Abort::Package;
use v5.12.0;
use Moo;

has public => (
is => 'ro',
default => 0,
);

has message => (
is => 'ro',
required => 1,
);

no Moo;
1;
174 changes: 174 additions & 0 deletions lib/PAUSE/Indexer/Context.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
package PAUSE::Indexer::Context;
use v5.12.0;
use Moo;

use PAUSE::Indexer::Abort::Dist;
use PAUSE::Indexer::Abort::Package;
use PAUSE::Indexer::Errors;
use PAUSE::Logger '$Logger';

has package_warnings => (
is => 'bare',
reader => '_package_warnings',
default => sub { {} },
);

sub add_package_warning {
my ($self, $package_obj, $warning) = @_;

my $package = $package_obj->{PACKAGE};
my $pmfile = $package_obj->pmfile->{PMFILE};

my $key = "$package\0$pmfile";

my $list = ($self->_package_warnings->{$key} //= []);
push @$list, {
package => $package,
pmfile => $pmfile,
text => $warning,
};

$Logger->log([
"adding package warning to %s: %s",
$package_obj->{PACKAGE},
$list->[-1],
]);

return;
}

has package_status => (
is => 'bare',
reader => '_package_status',
default => sub { {} },
);

sub _set_package_error {
my ($self, $package_obj, $status) = @_;

$self->_package_status->{ $package_obj->{PACKAGE} } = {
is_success => 0,
filename => $package_obj->{PP}{infile},
version => $package_obj->{PP}{version},
header => $status->{header},
body => $status->{body},
package => $package_obj->{PACKAGE},
};

$Logger->log([
"set error status for %s to %s",
$package_obj->{PACKAGE},
$status,
]);

return;
}

sub record_package_indexing {
my ($self, $package_obj) = @_;

$self->_package_status->{ $package_obj->{PACKAGE} } = {
is_success => 1,
filename => $package_obj->{PP}{infile},
version => $package_obj->{PP}{version},
header => "Indexed successfully",
body => "The package was indexed successfully.",
package => $package_obj->{PACKAGE},
};

$Logger->log([
"set OK status for %s",
$package_obj->{PACKAGE},
]);

return;
}

sub package_statuses {
my ($self) = @_;

my %stash = $self->_package_status->%*;
return @stash{ sort keys %stash };
}

sub abort_indexing_package {
my ($self, $package_obj, $error) = @_;

$Logger->log("abort indexing $package_obj->{PACKAGE}");

$self->_set_package_error($package_obj, $error);

die PAUSE::Indexer::Abort::Package->new({
message => $error->{header},
public => 1,
});
}

sub warnings_for_all_packages {
my ($self) = @_;

return map {; @$_ } values $self->_package_warnings->%*;
}

sub warnings_for_package {
my ($self, $package_name) = @_;

return grep {; $_->{package} eq $package_name }
$self->warnings_for_all_packages;
}

has alerts => (
is => 'bare',
reader => '_alerts',
default => sub { [] },
);

sub add_alert {
my ($self, $alert) = @_;
$alert =~ s/\v+\z//;

push $self->_alerts->@*, $alert;
return;
}

sub all_alerts {
my ($self) = @_;
return $self->_alerts->@*;
}

has dist_errors => (
is => 'bare',
reader => '_dist_errors',
default => sub { [] },
);

sub add_dist_error {
my ($self, $error) = @_;

$Logger->log_fatal([ "add_dist_error got bogus input: %s", $error ])
unless ref $error and $error->{header};

$Logger->log([ "adding dist error: %s", $error->{header} ]);
push $self->_dist_errors->@*, $error;

return;
}

sub all_dist_errors {
my ($self) = @_;
return $self->_dist_errors->@*;
}

sub abort_indexing_dist {
my ($self, $error) = @_;

$self->add_dist_error($error);

die PAUSE::Indexer::Abort::Dist->new({
message => $error->{header},
public => $error->{public},
});
}

no Moo;
1;
Loading
Loading