Browse Source

replace_file

pull/342/head
chenjing 3 years ago
parent
commit
769f888f3e
2 changed files with 15 additions and 0 deletions
  1. +14
    -0
      app/controllers/repositories_controller.rb
  2. +1
    -0
      config/routes.rb

+ 14
- 0
app/controllers/repositories_controller.rb 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?


+ 1
- 0
config/routes.rb 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


Loading…
Cancel
Save