2013-07-16 20:12:52 +00:00
|
|
|
class Projects::TagsController < Projects::ApplicationController
|
|
|
|
# Authorize
|
|
|
|
before_filter :authorize_read_project!
|
|
|
|
before_filter :require_non_empty_project
|
|
|
|
|
2013-07-17 05:26:00 +00:00
|
|
|
before_filter :authorize_code_access!
|
|
|
|
before_filter :authorize_push!, only: [:create]
|
|
|
|
before_filter :authorize_admin_project!, only: [:destroy]
|
2013-07-16 20:12:52 +00:00
|
|
|
|
|
|
|
def index
|
2014-02-03 16:13:24 +00:00
|
|
|
@tags = Kaminari.paginate_array(@repository.tags.reverse).page(params[:page]).per(30)
|
2013-07-16 20:12:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2013-07-17 12:11:03 +00:00
|
|
|
@repository.add_tag(params[:tag_name], params[:ref])
|
|
|
|
|
|
|
|
if new_tag = @repository.find_tag(params[:tag_name])
|
|
|
|
Event.create_ref_event(@project, current_user, new_tag, 'add', 'refs/tags')
|
|
|
|
end
|
2013-07-17 11:43:18 +00:00
|
|
|
|
|
|
|
redirect_to project_tags_path(@project)
|
2013-07-16 20:12:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2013-07-17 12:11:03 +00:00
|
|
|
tag = @repository.find_tag(params[:id])
|
2013-07-16 20:12:52 +00:00
|
|
|
|
2013-07-17 12:11:03 +00:00
|
|
|
if tag && @repository.rm_tag(tag.name)
|
|
|
|
Event.create_ref_event(@project, current_user, tag, 'rm', 'refs/tags')
|
2013-07-16 20:12:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to project_tags_path }
|
|
|
|
format.js { render nothing: true }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|