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
12b779e7
Commit
12b779e7
authored
Mar 13, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move tag deletion to service and execute hooks and services.
parent
10421674
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
6 deletions
+47
-6
app/controllers/projects/tags_controller.rb
app/controllers/projects/tags_controller.rb
+5
-6
app/services/delete_tag_service.rb
app/services/delete_tag_service.rb
+42
-0
No files found.
app/controllers/projects/tags_controller.rb
View file @
12b779e7
...
...
@@ -24,14 +24,13 @@ class Projects::TagsController < Projects::ApplicationController
end
def
destroy
tag
=
@repository
.
find_tag
(
params
[
:id
])
if
tag
&&
@repository
.
rm_tag
(
tag
.
name
)
EventCreateService
.
new
.
push_ref
(
@project
,
current_user
,
tag
,
'rm'
,
Gitlab
::
Git
::
TAG_REF_PREFIX
)
end
DeleteTagService
.
new
(
project
,
current_user
).
execute
(
params
[
:id
])
respond_to
do
|
format
|
format
.
html
{
redirect_to
namespace_project_tags_path
}
format
.
html
do
redirect_to
namespace_project_tags_path
(
@project
.
namespace
,
@project
)
end
format
.
js
end
end
...
...
app/services/delete_tag_service.rb
0 → 100644
View file @
12b779e7
require_relative
'base_service'
class
DeleteTagService
<
BaseService
def
execute
(
tag_name
)
repository
=
project
.
repository
tag
=
repository
.
find_tag
(
tag_name
)
# No such tag
unless
tag
return
error
(
'No such tag'
,
404
)
end
if
repository
.
rm_tag
(
tag_name
)
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
)
success
(
'Tag was removed'
)
else
error
(
'Failed to remove tag'
)
end
end
def
error
(
message
,
return_code
=
400
)
out
=
super
(
message
)
out
[
:return_code
]
=
return_code
out
end
def
success
(
message
)
out
=
super
()
out
[
:message
]
=
message
out
end
def
build_push_data
(
tag
)
Gitlab
::
PushDataBuilder
.
build
(
project
,
current_user
,
tag
.
target
,
Gitlab
::
Git
::
BLANK_SHA
,
"
#{
Gitlab
::
Git
::
TAG_REF_PREFIX
}#{
tag
.
name
}
"
,
[])
end
end
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