2022-07-19 16:47:01 +08:00
|
|
|
|
class Api::V1::Projects::ContentsController < Api::V1::BaseController
|
2022-08-01 17:14:32 +08:00
|
|
|
|
before_action :require_operate_above_or_fork_project, only: [:batch]
|
2022-07-19 16:47:01 +08:00
|
|
|
|
|
|
|
|
|
|
def batch
|
2022-07-28 14:25:33 +08:00
|
|
|
|
@batch_content_params = batch_content_params
|
|
|
|
|
|
# 处理下author和committer信息,如果没传则默认为当前用户信息
|
|
|
|
|
|
@batch_content_params.merge!(author_email: current_user.mail, author_name: current_user.login) if batch_content_params[:author_email].blank? && batch_content_params[:author_name].blank?
|
|
|
|
|
|
@batch_content_params.merge!(committer_email: current_user.mail, committer_name: current_user.login) if batch_content_params[:committer_email].blank? && batch_content_params[:committer_name].blank?
|
2022-08-01 17:14:32 +08:00
|
|
|
|
|
|
|
|
|
|
@result_object = Api::V1::Projects::Contents::BatchCreateService.call(@project, @batch_content_params, @project.owner.gitea_token)
|
2022-07-19 16:47:01 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
def batch_content_params
|
|
|
|
|
|
params.require(:content).permit(:author_email, :author_name, :author_timeunix, :branch, :committer_email, :committer_name, :committer_timeunix, :message, :new_branch, files: [ :action_type, :content, :encoding, :file_path])
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|