From 198451435d669e388e5963fe0667e0460b8c75dc Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 9 Mar 2020 12:11:12 -0700 Subject: Implement API::GitForge::GitLab::_ensure_repo() Signed-off-by: Sean Whitton --- lib/API/GitForge/GitLab.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/API/GitForge/GitLab.pm b/lib/API/GitForge/GitLab.pm index f4baaad..3f38bf7 100644 --- a/lib/API/GitForge/GitLab.pm +++ b/lib/API/GitForge/GitLab.pm @@ -111,8 +111,17 @@ sub _clean_config_fork { } sub _ensure_repo { - # TODO - 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 { -- cgit v1.2.3