2013-07-16 20:12:52 +00:00
|
|
|
class Projects::TagsController < Projects::ApplicationController
|
|
|
|
# Authorize
|
2015-04-16 12:03:37 +00:00
|
|
|
before_action :require_non_empty_project
|
|
|
|
before_action :authorize_download_code!
|
2015-12-03 17:53:17 +00:00
|
|
|
before_action :authorize_push_code!, only: [:new, :create]
|
2015-04-16 12:03:37 +00:00
|
|
|
before_action :authorize_admin_project!, only: [:destroy]
|
2013-07-16 20:12:52 +00:00
|
|
|
|
|
|
|
def index
|
2014-04-14 16:39:24 +00:00
|
|
|
sorted = VersionSorter.rsort(@repository.tag_names)
|
2015-03-12 22:37:00 +00:00
|
|
|
@tags = Kaminari.paginate_array(sorted).page(params[:page]).per(PER_PAGE)
|
2015-11-05 12:49:34 +00:00
|
|
|
@releases = project.releases.where(tag: @tags)
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
@tag = @repository.find_tag(params[:id])
|
|
|
|
@release = @project.releases.find_or_initialize_by(tag: @tag.name)
|
|
|
|
@commit = @repository.commit(@tag.target)
|
2013-07-16 20:12:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2014-09-21 08:29:52 +00:00
|
|
|
result = CreateTagService.new(@project, current_user).
|
2015-11-09 14:39:18 +00:00
|
|
|
execute(params[:tag_name], params[:ref], params[:message], params[:release_description])
|
2015-01-12 07:51:31 +00:00
|
|
|
|
2014-07-27 17:56:33 +00:00
|
|
|
if result[:status] == :success
|
|
|
|
@tag = result[:tag]
|
2015-11-05 13:03:48 +00:00
|
|
|
|
2015-11-05 13:07:55 +00:00
|
|
|
redirect_to namespace_project_tag_path(@project.namespace, @project, @tag.name)
|
2014-07-27 17:56:33 +00:00
|
|
|
else
|
|
|
|
@error = result[:message]
|
|
|
|
render action: 'new'
|
|
|
|
end
|
2013-07-16 20:12:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2015-03-13 13:56:53 +00:00
|
|
|
DeleteTagService.new(project, current_user).execute(params[:id])
|
2013-07-16 20:12:52 +00:00
|
|
|
|
2016-03-01 17:42:56 +00:00
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
|
|
|
redirect_to namespace_project_tags_path(@project.namespace, @project)
|
|
|
|
end
|
|
|
|
format.js
|
|
|
|
end
|
2013-07-16 20:12:52 +00:00
|
|
|
end
|
|
|
|
end
|