summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-03-09 12:11:12 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-03-09 12:12:14 -0700
commit198451435d669e388e5963fe0667e0460b8c75dc (patch)
tree092badf8f7561036ccdf0f780af073fa5b32f582
parent6545565d13b6748057f632ea1834f21e722f8a79 (diff)
downloadp5-API-GitForge-198451435d669e388e5963fe0667e0460b8c75dc.tar.gz
Implement API::GitForge::GitLab::_ensure_repo()
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--Changes1
-rw-r--r--lib/API/GitForge/GitLab.pm13
2 files changed, 12 insertions, 2 deletions
diff --git a/Changes b/Changes
index 1f4e1f1..41ade93 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
Revision history for API::GitForge
{{$NEXT}}
+ - Implement API::GitForge::GitLab::_ensure_repo().
- Add git repo metadata to dist.ini.
- Don't disable merge requests in GitLab clean forks.
Otherwise we can't submit merge requests upstream.
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 {