Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
54df1a57
Commit
54df1a57
authored
Dec 31, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve a Cognitive Complexity of 12
parent
8f1e96c8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
+18
-12
app/services/releases/create_service.rb
app/services/releases/create_service.rb
+18
-12
No files found.
app/services/releases/create_service.rb
View file @
54df1a57
...
@@ -8,24 +8,30 @@ module Releases
...
@@ -8,24 +8,30 @@ 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
)
return
error
(
'Ref is not specified'
,
422
)
unless
ref
result
=
Tags
::
CreateService
create_release
(
tag
)
.
new
(
project
,
current_user
)
end
.
execute
(
tag_name
,
ref
,
nil
)
return
result
unless
result
[
:status
]
==
:success
new_tag
=
result
[
:tag
]
private
end
create_release
(
existing_tag
||
new_tag
)
def
ensure_tag
existing_tag
||
create_tag
end
end
private
def
create_tag
return
error
(
'Ref is not specified'
,
422
)
unless
ref
result
=
Tags
::
CreateService
.
new
(
project
,
current_user
)
.
execute
(
tag_name
,
ref
,
nil
)
return
result
unless
result
[
:status
]
==
:success
result
[
:tag
]
end
def
allowed?
def
allowed?
Ability
.
allowed?
(
current_user
,
:create_release
,
project
)
Ability
.
allowed?
(
current_user
,
:create_release
,
project
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment