diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-03-09 13:24:37 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-03-09 13:24:37 -0700 |
commit | 0ae4bf932c0808123d9e8149f5c7fedd10f6c2b7 (patch) | |
tree | 7e3d5df2bed023817d1773cfb500b402e160fae0 | |
parent | a7b92281eaa19d1d2e36c7d0fd4d1359a2469e99 (diff) | |
download | p5-API-GitForge-0ae4bf932c0808123d9e8149f5c7fedd10f6c2b7.tar.gz |
don't look up namespace if project already exists
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r-- | Changes | 2 | ||||
-rw-r--r-- | lib/API/GitForge/GitLab.pm | 6 |
2 files changed, 3 insertions, 5 deletions
@@ -1,6 +1,8 @@ Revision history for API::GitForge {{$NEXT}} + - API::GitForge::GitLab::_ensure_repo(): avoid an unnecessary API + call. 0.002 2020-03-09 12:17:47-07:00 America/Phoenix - Implement API::GitForge::GitLab::_ensure_repo(). diff --git a/lib/API/GitForge/GitLab.pm b/lib/API/GitForge/GitLab.pm index 3f38bf7..2091cfc 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} }); } |