diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index f80e00b6f..f729ab394 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -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? diff --git a/config/routes.rb b/config/routes.rb index 0e760fbe9..f36aaa165 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -526,6 +526,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