summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-03-09 13:24:37 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-03-09 13:24:37 -0700
commit0ae4bf932c0808123d9e8149f5c7fedd10f6c2b7 (patch)
tree7e3d5df2bed023817d1773cfb500b402e160fae0
parenta7b92281eaa19d1d2e36c7d0fd4d1359a2469e99 (diff)
downloadp5-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--Changes2
-rw-r--r--lib/API/GitForge/GitLab.pm6
2 files changed, 3 insertions, 5 deletions
diff --git a/Changes b/Changes
index 5f6e9bf..a51c982 100644
--- a/Changes
+++ b/Changes
@@ -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} });
}