Subject: | Upload failures with Mojolicious 7.0+ |
Hi,
This might be caused by Mojolicious API changes, but the current version of UploadToStratopan fails the login step.
Attached patch works for me.
cheers,
Tom
Subject: | 2016-09-22-stratopan-mojo-fixes.patch |
diff --git a/lib/Dist/Zilla/Plugin/UploadToStratopan.pm b/lib/Dist/Zilla/Plugin/UploadToStratopan.pm
index f4081ca..54d4894 100644
--- a/lib/Dist/Zilla/Plugin/UploadToStratopan.pm
+++ b/lib/Dist/Zilla/Plugin/UploadToStratopan.pm
@@ -67,14 +67,15 @@ sub release {
$tarball = "$tarball"; # stringify object
my $ua = $self->_ua;
+ $ua->max_redirects(3);
my $tx = $ua->post( $self->_strato_base . '/signin',
form => {
login => $self->_username,
password => $self->_password
} );
- if ( my $error = $tx->res->dom->find( 'div#page-alert p' ) ) {
- $self->log_fatal( $error->all_text );
+ if ( my $error = $tx->res->dom->find( 'div#page-alert p' )->first ) {
+ $self->log_fatal( $error->map('text')->join(" ") );
}
my $submit_url = sprintf '%s/%s/%s/%s/stack/add',
@@ -89,11 +90,11 @@ sub release {
}
);
- if ( $tx->res->code == 302 ) {
+ if ( $tx->res->code == 302 or $tx->res->code =~ /^2/ ) {
return $self->log( "success." );
}
- $self->log_fatal( $tx->res->dom->find( 'div#page-alert p' )->all_text );
+ $self->log_fatal( $tx->res->dom->find( 'div#page-alert p' )->map('text')->join(" ") );
}