replace_file

This commit is contained in:
chenjing 2023-05-06 01:15:00 +08:00
parent 1e7cffd716
commit 769f888f3e
2 changed files with 15 additions and 0 deletions

View File

@ -211,6 +211,20 @@ class RepositoriesController < ApplicationController
end
end
def replace_file
#删除
delete_interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, params[:delete_file].merge(identifier: @project.identifier))
return render_error(delete_interactor.error) unless delete_interactor.success?
#新建
interactor = Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params)
if interactor.success?
@file = interactor.result
else
render_error(interactor.error)
end
end
def delete_file
interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, params.merge(identifier: @project.identifier))
if interactor.success?

View File

@ -498,6 +498,7 @@ Rails.application.routes.draw do
get :tags
get :contributors
post :create_file
post :replace_file
put :update_file
delete :delete_file
post :repo_hook