Add support for gitlab.com releases

Uses the GitLab API for finding releases.
Supports both source archives and links.

Requested-by: Ben Finney <bignose>
parent 5856ca24
......@@ -53,6 +53,7 @@ my $pypi_project_char_re = '[a-zA-Z0-9\-\.]';
my $npmjs_project_char_re = '[a-zA-Z0-9\-\._@/]';
my $cratesio_project_char_re = '[a-zA-Z0-9_.-]';
my $github_project_char_re = '[-_.a-zA-Z0-9]';
my $gitlab_project_char_re = '[-_.a-zA-Z0-9]';
my $hg_repository_re = '[a-zA-Z0-9\.\-:/]+';
my $href_char_re = '[a-zA-Z0-9\-\._/]';
my $href_p_char_re = '[a-zA-Z0-9\-\._/%]';
......@@ -938,6 +939,47 @@ elsif( $upstream_param =~ m%^github_commits_package_json/($github_project_char_r
}
# https://gitlab.com/ercom/citbx4gitlab/releases
# http://qa.debian.org/cgi-bin/fakeupstream.cgi?upstream=gitlab_releases/ercom/citbx4gitlab
elsif( $upstream_param =~ m%^gitlab_releases/($gitlab_project_char_re+)/($gitlab_project_char_re+)% )
{
my $org = $1;
my $project = $2;
my $url = "https://gitlab.com/api/v4/projects/$org%2F$project/releases";
my $ua = LWP::UserAgent->new;
my $response = $ua->get( $url );
return_error( "failed to read $url : $response->status_line" ) if( not $response->is_success );
my $json = JSON::decode_json( $response->decoded_content );
print $q->header;
print $q->start_html;
print $q->start_ul;
foreach my $vers ( @{$json} )
{
my $version = $vers->{'tag_name'};
print $q->start_li;
print $q->escapeHTML( $version ); print ' ';
foreach my $source ( @{$vers->{'assets'}->{'sources'}} )
{
my $format = $source->{'format'};
my $dl_uri = URI->new_abs($source->{'url'}, $url);
print $q->a( { -href => $dl_uri }, $format ); print ' ';
}
foreach my $link ( @{$vers->{'assets'}->{'links'}} )
{
my $name = $link->{'name'};
my $dl_uri = URI->new_abs($link->{'url'}, $url);
print $q->a( { -href => $dl_uri }, $name ); print ' ';
}
print $q->end_li;
}
print $q->end_ul;
print $q->end_html;
exit 0;
}
# https://tracker.debian.org/pkg/cargo
# https://crates.io/crates/cargo
# http://qa.debian.org/cgi-bin/fakeupstream.cgi?upstream=crates.io/cargo
......
Markdown is supported
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