BigW Consortium Gitlab

Commit 613856fa by dixpac

Move tag services to `Tags` namespace

CreateTagService and DeleteTagService where in root namespace, by following service code organization I moved them in Tags::CreateService and Tags::DestroyService
parent f802ad37
......@@ -27,7 +27,7 @@ class Projects::TagsController < Projects::ApplicationController
end
def create
result = CreateTagService.new(@project, current_user).
result = Tags::CreateService.new(@project, current_user).
execute(params[:tag_name], params[:ref], params[:message], params[:release_description])
if result[:status] == :success
......@@ -41,7 +41,7 @@ class Projects::TagsController < Projects::ApplicationController
end
def destroy
DeleteTagService.new(project, current_user).execute(params[:id])
Tags::DestroyService.new(project, current_user).execute(params[:id])
respond_to do |format|
format.html do
......
class CreateTagService < BaseService
module Tags
class CreateService < BaseService
def execute(tag_name, target, message, release_description = nil)
valid_tag = Gitlab::GitRefValidator.validate(tag_name)
return error('Tag name invalid') unless valid_tag
......@@ -27,4 +28,5 @@ class CreateTagService < BaseService
error("Target #{target} is invalid")
end
end
end
end
class DeleteTagService < BaseService
module Tags
class DestroyService < BaseService
def execute(tag_name)
repository = project.repository
tag = repository.find_tag(tag_name)
......@@ -39,4 +40,5 @@ class DeleteTagService < BaseService
"#{Gitlab::Git::TAG_REF_PREFIX}#{tag.name}",
[])
end
end
end
---
title: Move tag services to Tags namespace
merge_request:
author: dixpac
......@@ -40,7 +40,7 @@ module API
post ':id/repository/tags' do
authorize_push_project
result = CreateTagService.new(user_project, current_user).
result = ::Tags::CreateService.new(user_project, current_user).
execute(params[:tag_name], params[:ref], params[:message], params[:release_description])
if result[:status] == :success
......@@ -59,7 +59,7 @@ module API
delete ":id/repository/tags/:tag_name", requirements: { tag_name: /.+/ } do
authorize_push_project
result = DeleteTagService.new(user_project, current_user).
result = ::Tags::DestroyService.new(user_project, current_user).
execute(params[:tag_name])
if result[:status] == :success
......
require 'spec_helper'
describe CreateTagService, services: true do
describe Tags::CreateService, services: true do
let(:project) { create(:project) }
let(:repository) { project.repository }
let(:user) { create(:user) }
......
require 'spec_helper'
describe DeleteTagService, services: true do
describe Tags::DestroyService, services: true do
let(:project) { create(:project) }
let(:repository) { project.repository }
let(:user) { create(:user) }
......
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