12ee2753c1
Enables frozen string for some vestigial files as well as the following: * app/controllers/projects/**/*.rb * app/controllers/sherlock/**/*.rb * app/controllers/snippets/**/*.rb * app/controllers/users/**/*.rb Partially addresses #47424.
42 lines
1 KiB
Ruby
42 lines
1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class Projects::ReleasesController < Projects::ApplicationController
|
|
# Authorize
|
|
before_action :require_non_empty_project
|
|
before_action :authorize_download_code!
|
|
before_action :authorize_push_code!
|
|
before_action :tag
|
|
before_action :release
|
|
|
|
def edit
|
|
end
|
|
|
|
def update
|
|
# Release belongs to Tag which is not active record object,
|
|
# it exists only to save a description to each Tag.
|
|
# If description is empty we should destroy the existing record.
|
|
if release_params[:description].present?
|
|
release.update(release_params)
|
|
else
|
|
release.destroy
|
|
end
|
|
|
|
redirect_to project_tag_path(@project, @tag.name)
|
|
end
|
|
|
|
private
|
|
|
|
def tag
|
|
@tag ||= @repository.find_tag(params[:tag_id])
|
|
end
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
|
def release
|
|
@release ||= @project.releases.find_or_initialize_by(tag: @tag.name)
|
|
end
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
|
|
|
def release_params
|
|
params.require(:release).permit(:description)
|
|
end
|
|
end
|