summaryrefslogtreecommitdiff
path: root/lib/API/GitForge/GitLab.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/API/GitForge/GitLab.pm')
-rw-r--r--lib/API/GitForge/GitLab.pm28
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/API/GitForge/GitLab.pm b/lib/API/GitForge/GitLab.pm
index 7ffd844..3f38bf7 100644
--- a/lib/API/GitForge/GitLab.pm
+++ b/lib/API/GitForge/GitLab.pm
@@ -70,12 +70,11 @@ sub _ensure_fork {
sub _assert_fork_has_parent {
my ($self, $upstream) = @_;
- my (undef, $repo) = _extract_project_id($upstream);
+ my ($path, $repo) = _extract_project_id($upstream);
my $user = $self->{_api}->current_user->{username};
my $fork = $self->{_api}->project("$user/$repo");
- $upstream =~ s/\.git$//;
- $fork->{forked_from_project}{path_with_namespace} eq $upstream
+ $fork->{forked_from_project}{path_with_namespace} eq $path . "/" . $repo
or croak
"$user/$repo does not have parent $upstream; don't know what to do";
}
@@ -101,15 +100,28 @@ sub _clean_config_fork {
$self->{_api}->edit_project(
"$user/$repo",
{
- default_branch => "gitforge",
- description => "Temporary fork for merge request(s)",
+ default_branch => "gitforge",
+ description => "Temporary fork for merge request(s)",
+ issues_access_level => "disabled",
+ # merge requests have to be enabled in the fork in order
+ # to submit merge requests to the upstream repo from which
+ # we forked, it seems
+ merge_requests_access_level => "enabled",
});
-
- $self->_clean_config_repo("$user/$repo");
}
sub _ensure_repo {
- die "unimplemented";
+ my ($self, $target) = @_;
+ my ($ns, $repo) = _extract_project_id($target);
+
+ # first we are required to get the namespace id
+ my $namespace = $self->{_api}->namespace($ns)
+ or croak "invalid project namespace $ns";
+
+ # now create the project unless it already exists
+ return if $self->{_api}->project($target);
+ $self->{_api}
+ ->create_project({ name => $repo, namespace_id => $namespace->{id} });
}
sub _nuke_fork {