Commit e96f92d3 authored by Michael Friedrich's avatar Michael Friedrich 💬
Browse files

Perl: Add paginated commit fetch

parent 8b5d079f
......@@ -5,6 +5,7 @@ use warnings;
use GitLab::API::v4;
use Data::Dumper;
use Try::Tiny;
use feature qw(switch say);
my $project_id= 15730252; # this project
......@@ -20,6 +21,8 @@ my %params;
my $branches = $api->branches( $project_id );
#say Dumper($branches);
say "======== Commits ========";
my $commits = $api->commits(
$project_id,
\%params,
......@@ -32,3 +35,34 @@ foreach(@{$commits}) {
push @coll_commits, $c->{'title'};
}
say join("\n", @coll_commits);
say "======== Paginated Commits ========";
my $history = [];
my $gitLabHistory = $api->paginator('commits', $project_id, \%params);
if ($gitLabHistory->isa('GitLab::API::v4::Paginator')) {
PAGE: while(1) {
my $commits = [];
try {
$commits = $gitLabHistory->next_page();
} catch {
$commits = [];
if ($_) {
print "Can't get history: $_\n";
}
};
last PAGE unless (ref $commits eq 'ARRAY' && @{$commits});
push @{$history}, @{$commits};
}
}
my @history_short_log;
foreach(@{$history}) {
my $c = $_;
push @history_short_log, $c->{'title'};
}
say join("\n", @history_short_log);
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