summaryrefslogtreecommitdiff
path: root/contrib/mw-to-git/git-remote-mediawiki.perl
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2013-05-29 12:06:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-05-29 17:00:32 (GMT)
commit0aa0321212d6b817783616af4ba1353a46b82179 (patch)
tree31c65555c580bbf8253a15ddef8be0c1fb9a22db /contrib/mw-to-git/git-remote-mediawiki.perl
parent92758dd2a2de94c90c0697ef0e8174c3543a47f9 (diff)
downloadgit-0aa0321212d6b817783616af4ba1353a46b82179.zip
git-0aa0321212d6b817783616af4ba1353a46b82179.tar.gz
git-0aa0321212d6b817783616af4ba1353a46b82179.tar.bz2
git-remote-mediawiki: better error message when HTTP(S) access fails
My use-case is an invalid SSL certificate. Pulling from the wiki with a recent version of libwww-perl fails, and git-remote-mediawiki gave no clue about the reason. Give the mediawiki API detailed error message, and since it is not so informative, hint the user about an invalid SSL certificate on https:// urls. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/mw-to-git/git-remote-mediawiki.perl')
-rwxr-xr-xcontrib/mw-to-git/git-remote-mediawiki.perl26
1 files changed, 18 insertions, 8 deletions
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index 9c14c1f..f0c348c 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -238,6 +238,22 @@ sub mw_connect_maybe {
}
}
+sub fatal_mw_error {
+ my $action = shift;
+ print STDERR "fatal: could not $action.\n";
+ print STDERR "fatal: '$url' does not appear to be a mediawiki\n";
+ if ($url =~ /^https/) {
+ print STDERR "fatal: make sure '$url/api.php' is a valid page\n";
+ print STDERR "fatal: and the SSL certificate is correct.\n";
+ } else {
+ print STDERR "fatal: make sure '$url/api.php' is a valid page.\n";
+ }
+ print STDERR "fatal: (error " .
+ $mediawiki->{error}->{code} . ': ' .
+ $mediawiki->{error}->{details} . ")\n";
+ exit 1;
+}
+
## Functions for listing pages on the remote wiki
sub get_mw_tracked_pages {
my $pages = shift;
@@ -290,10 +306,7 @@ sub get_mw_all_pages {
aplimit => 'max'
});
if (!defined($mw_pages)) {
- print STDERR "fatal: could not get the list of wiki pages.\n";
- print STDERR "fatal: '$url' does not appear to be a mediawiki\n";
- print STDERR "fatal: make sure '$url/api.php' is a valid page.\n";
- exit 1;
+ fatal_mw_error("get the list of wiki pages");
}
foreach my $page (@{$mw_pages}) {
$pages->{$page->{title}} = $page;
@@ -316,10 +329,7 @@ sub get_mw_first_pages {
titles => $titles,
});
if (!defined($mw_pages)) {
- print STDERR "fatal: could not query the list of wiki pages.\n";
- print STDERR "fatal: '$url' does not appear to be a mediawiki\n";
- print STDERR "fatal: make sure '$url/api.php' is a valid page.\n";
- exit 1;
+ fatal_mw_error("query the list of wiki pages");
}
while (my ($id, $page) = each(%{$mw_pages->{query}->{pages}})) {
if ($id < 0) {