Commit c89bbd79 authored by Roman Lacko's avatar Roman Lacko
Browse files

add API version test in GitLab::API

parent 4edc8590
...@@ -22,7 +22,7 @@ use GitLab::API::Iterator; ...@@ -22,7 +22,7 @@ use GitLab::API::Iterator;
use parent "Exporter"; use parent "Exporter";
our $VERSION = 8.12.1; our $VERSION = 10.2.4;
my %defaults = ( my %defaults = (
per_page => 50, per_page => 50,
...@@ -49,6 +49,15 @@ sub new { ...@@ -49,6 +49,15 @@ sub new {
$args{URL} = "$s://$args{Host}/api/v$v"; $args{URL} = "$s://$args{Host}/api/v$v";
} }
my ($req_version) = ($args{URL} =~ m!api/v(\d+)!);
if (!defined $req_version) {
carp "Cannot determine requested version of API";
} elsif ($req_version < 4) {
carp "API version $req_version is deprecated";
} elsif ($req_version > 4) {
croak "API version $req_version is not supported";
}
$log->debug("initializing GitLab::API for \"$args{URL}\""); $log->debug("initializing GitLab::API for \"$args{URL}\"");
my $self = { my $self = {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment