2014-09-02 18:07:02 +05:30
|
|
|
class Projects::TagsController < Projects::ApplicationController
|
|
|
|
# Authorize
|
2015-09-11 14:41:01 +05:30
|
|
|
before_action :require_non_empty_project
|
|
|
|
before_action :authorize_download_code!
|
|
|
|
before_action :authorize_push_code!, only: [:create]
|
|
|
|
before_action :authorize_admin_project!, only: [:destroy]
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
def index
|
|
|
|
sorted = VersionSorter.rsort(@repository.tag_names)
|
2015-04-26 12:48:37 +05:30
|
|
|
@tags = Kaminari.paginate_array(sorted).page(params[:page]).per(PER_PAGE)
|
2015-11-26 14:37:03 +05:30
|
|
|
@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)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2015-04-26 12:48:37 +05:30
|
|
|
result = CreateTagService.new(@project, current_user).
|
2015-11-26 14:37:03 +05:30
|
|
|
execute(params[:tag_name], params[:ref], params[:message], params[:release_description])
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
if result[:status] == :success
|
|
|
|
@tag = result[:tag]
|
2015-11-26 14:37:03 +05:30
|
|
|
|
|
|
|
redirect_to namespace_project_tag_path(@project.namespace, @project, @tag.name)
|
2015-04-26 12:48:37 +05:30
|
|
|
else
|
|
|
|
@error = result[:message]
|
|
|
|
render action: 'new'
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2015-04-26 12:48:37 +05:30
|
|
|
DeleteTagService.new(project, current_user).execute(params[:id])
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-11-26 14:37:03 +05:30
|
|
|
redirect_to namespace_project_tags_path(@project.namespace, @project)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|