diff options
Diffstat (limited to 'lib/API/GitForge/GitLab.pm')
-rw-r--r-- | lib/API/GitForge/GitLab.pm | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/API/GitForge/GitLab.pm b/lib/API/GitForge/GitLab.pm index 3f38bf7..1e620d8 100644 --- a/lib/API/GitForge/GitLab.pm +++ b/lib/API/GitForge/GitLab.pm @@ -113,13 +113,9 @@ sub _clean_config_fork { sub _ensure_repo { my ($self, $target) = @_; my ($ns, $repo) = _extract_project_id($target); - - # first we are required to get the namespace id + return if $self->{_api}->project($target); 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} }); } @@ -132,6 +128,14 @@ sub _nuke_fork { $self->{_api}->delete_project("$user/$repo"); } +sub _ensure_fork_branch_unprotected { + my ($self, $upstream, $branch) = @_; + my (undef, $repo) = _extract_project_id($upstream); + my $user = $self->{_api}->current_user->{username}; + return unless $self->{_api}->protected_branch("$user/$repo", $branch); + $self->{_api}->unprotect_branch("$user/$repo", $branch); +} + sub _extract_project_id { my $project = shift; $project =~ s#(?:\.git)?/?$##; |