Commit 54df1a57 authored by Shinya Maeda's avatar Shinya Maeda

Resolve a Cognitive Complexity of 12

parent 8f1e96c8
...@@ -8,9 +8,20 @@ module Releases ...@@ -8,9 +8,20 @@ module Releases
return error('Access Denied', 403) unless allowed? return error('Access Denied', 403) unless allowed?
return error('Release already exists', 409) if release return error('Release already exists', 409) if release
new_tag = nil tag = ensure_tag
unless tag_exist? return tag unless tag.is_a?(Gitlab::Git::Tag)
create_release(tag)
end
private
def ensure_tag
existing_tag || create_tag
end
def create_tag
return error('Ref is not specified', 422) unless ref return error('Ref is not specified', 422) unless ref
result = Tags::CreateService result = Tags::CreateService
...@@ -19,14 +30,9 @@ module Releases ...@@ -19,14 +30,9 @@ module Releases
return result unless result[:status] == :success return result unless result[:status] == :success
new_tag = result[:tag] result[:tag]
end
create_release(existing_tag || new_tag)
end end
private
def allowed? def allowed?
Ability.allowed?(current_user, :create_release, project) Ability.allowed?(current_user, :create_release, project)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment