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
Tatuya Kamada
gitlab-ce
Commits
b67fdfff
Commit
b67fdfff
authored
Nov 09, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor release code a bit
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
14518ba6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
15 deletions
+15
-15
app/controllers/projects/releases_controller.rb
app/controllers/projects/releases_controller.rb
+5
-3
app/controllers/projects/tags_controller.rb
app/controllers/projects/tags_controller.rb
+0
-8
app/models/release.rb
app/models/release.rb
+1
-1
app/services/create_tag_service.rb
app/services/create_tag_service.rb
+6
-2
app/services/delete_tag_service.rb
app/services/delete_tag_service.rb
+3
-1
No files found.
app/controllers/projects/releases_controller.rb
View file @
b67fdfff
...
...
@@ -10,9 +10,7 @@ class Projects::ReleasesController < Projects::ApplicationController
end
def
update
description
=
params
[
:release
][
:description
]
release
.
update_attributes
(
description:
description
)
release
.
save
release
.
update_attributes
(
release_params
)
redirect_to
namespace_project_tag_path
(
@project
.
namespace
,
@project
,
@tag
.
name
)
end
...
...
@@ -26,4 +24,8 @@ class Projects::ReleasesController < Projects::ApplicationController
def
release
@release
||=
@project
.
releases
.
find_or_initialize_by
(
tag:
@tag
.
name
)
end
def
release_params
params
.
require
(
:release
).
permit
(
:description
)
end
end
app/controllers/projects/tags_controller.rb
View file @
b67fdfff
...
...
@@ -24,12 +24,6 @@ class Projects::TagsController < Projects::ApplicationController
if
result
[
:status
]
==
:success
@tag
=
result
[
:tag
]
if
params
[
:release_description
]
release
=
@project
.
releases
.
find_or_initialize_by
(
tag:
@tag
.
name
)
release
.
update_attributes
(
description:
params
[
:release_description
])
release
.
save
end
redirect_to
namespace_project_tag_path
(
@project
.
namespace
,
@project
,
@tag
.
name
)
else
@error
=
result
[
:message
]
...
...
@@ -39,8 +33,6 @@ class Projects::TagsController < Projects::ApplicationController
def
destroy
DeleteTagService
.
new
(
project
,
current_user
).
execute
(
params
[
:id
])
release
=
project
.
releases
.
find_by
(
tag:
params
[
:id
])
release
.
destroy
if
release
redirect_to
namespace_project_tags_path
(
@project
.
namespace
,
@project
)
end
...
...
app/models/release.rb
View file @
b67fdfff
class
Release
<
ActiveRecord
::
Base
belongs_to
:project
validates
:description
,
:project
,
presence:
true
validates
:description
,
:project
,
:tag
,
presence:
true
end
app/services/create_tag_service.rb
View file @
b67fdfff
require_relative
'base_service'
class
CreateTagService
<
BaseService
def
execute
(
tag_name
,
ref
,
message
)
def
execute
(
tag_name
,
ref
,
message
,
release_description
=
nil
)
valid_tag
=
Gitlab
::
GitRefValidator
.
validate
(
tag_name
)
if
valid_tag
==
false
return
error
(
'Tag name invalid'
)
...
...
@@ -19,8 +19,12 @@ class CreateTagService < BaseService
new_tag
=
repository
.
find_tag
(
tag_name
)
if
new_tag
push_data
=
create_push_data
(
project
,
current_user
,
new_tag
)
if
release_description
release
=
project
.
releases
.
find_or_initialize_by
(
tag:
tag_name
)
release
.
update_attributes
(
description:
release_description
)
end
push_data
=
create_push_data
(
project
,
current_user
,
new_tag
)
EventCreateService
.
new
.
push
(
project
,
current_user
,
push_data
)
project
.
execute_hooks
(
push_data
.
dup
,
:tag_push_hooks
)
project
.
execute_services
(
push_data
.
dup
,
:tag_push_hooks
)
...
...
app/services/delete_tag_service.rb
View file @
b67fdfff
...
...
@@ -11,8 +11,10 @@ class DeleteTagService < BaseService
end
if
repository
.
rm_tag
(
tag_name
)
release
=
project
.
releases
.
find_by
(
tag:
tag_name
)
release
.
destroy
if
release
push_data
=
build_push_data
(
tag
)
EventCreateService
.
new
.
push
(
project
,
current_user
,
push_data
)
project
.
execute_hooks
(
push_data
.
dup
,
:tag_push_hooks
)
project
.
execute_services
(
push_data
.
dup
,
:tag_push_hooks
)
...
...
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