In order to access protected or private repositories. Using the target repository URL along with the merge-request ref instead of the source repository url and branch is necessary to avoid running into issues if the source repository is not actually accessible to the user Hydra is authenticating as.
Thanks Alexei Robyn for this patch.
PR4W2IUBHWKQ7BRFLXELHBVRU7VOSLKO4DVZIPSHLXZ422LWP2SQC
# The values source_repo_url and source_branch can then be used to
# build the git input value.
# The values `target_repo_url` and `iid` can then be used to
# build the git input value, e.g.:
# "${target_repo_url} merge-requests/${iid}/head".
# We need to query the Gitlab API for each merge request to get the
# source repository URL.
sub _enhanceGitlabPull {
my ($pull, $baseUrl, $ua) = @_;
my $projectId = $pull->{source_project_id};
(my $repo, my $res) = _query("$baseUrl/api/v4/projects/$projectId", $ua);
$pull->{source_repo_url} = $repo->{http_url_to_repo};
}
_iterate($url, $baseUrl, \%pulls, $ua);
$ua->default_header('Private-Token' => $accessToken) if defined $accessToken;
# Get the target project URL, as it is the one we need to build the pull
# urls from later
(my $repo, my $res) = _query("$baseUrl/api/v4/projects/$projectId", $ua);
my $target_repo_url = $repo->{http_url_to_repo};
_iterate($url, $baseUrl, \%pulls, $ua, $target_repo_url);