| @@ -235,9 +235,9 @@ class RepositoriesController < ApplicationController | |||||
| def readme | def readme | ||||
| if params[:filepath].present? | if params[:filepath].present? | ||||
| result = Gitea::Repository::Readme::DirService.call(@owner.login, @repository.identifier, params[:filepath], params[:ref], current_user&.gitea_token) | |||||
| result = Gitea::Repository::Readme::DirService.call(@owner.login, @repository.identifier, params[:filepath], params[:ref], @owner&.gitea_token) | |||||
| else | else | ||||
| result = Gitea::Repository::Readme::GetService.call(@owner.login, @repository.identifier, params[:ref], current_user&.gitea_token) | |||||
| result = Gitea::Repository::Readme::GetService.call(@owner.login, @repository.identifier, params[:ref], @owner&.gitea_token) | |||||
| end | end | ||||
| @path = GiteaService.gitea_config[:domain]+"/#{@owner.login}/#{@repository.identifier}/raw/branch/#{params[:ref]}/" | @path = GiteaService.gitea_config[:domain]+"/#{@owner.login}/#{@repository.identifier}/raw/branch/#{params[:ref]}/" | ||||
| @readme = result[:status] === :success ? result[:body] : nil | @readme = result[:status] === :success ? result[:body] : nil | ||||
| @@ -25,7 +25,7 @@ module Gitea | |||||
| def run | def run | ||||
| Contents::CreateForm.new(valid_params).validate! | Contents::CreateForm.new(valid_params).validate! | ||||
| result = Gitea::Repository::Entries::CreateService.call(token, | result = Gitea::Repository::Entries::CreateService.call(token, | ||||
| owner, @params[:identifier], @params[:filepath], file_params) | |||||
| owner, @params[:identifier], file_path, file_params) | |||||
| if result[:status] == :success | if result[:status] == :success | ||||
| @result = result[:body] | @result = result[:body] | ||||
| @@ -50,9 +50,17 @@ module Gitea | |||||
| @result = response | @result = response | ||||
| end | end | ||||
| def file_path | |||||
| if @params[:base64_filepath].present? | |||||
| Base64.decode64(params[:base64_filepath]) | |||||
| else | |||||
| @params[:filepath] | |||||
| end | |||||
| end | |||||
| def valid_params | def valid_params | ||||
| { | { | ||||
| filepath: @params[:filepath], | |||||
| filepath: file_path, | |||||
| branch: @params[:branch], | branch: @params[:branch], | ||||
| new_branch: @params[:new_branch] | new_branch: @params[:new_branch] | ||||
| } | } | ||||
| @@ -24,7 +24,7 @@ module Gitea | |||||
| def run | def run | ||||
| Contents::DeleteForm.new(valid_params).validate! | Contents::DeleteForm.new(valid_params).validate! | ||||
| response = Gitea::Repository::Entries::DeleteService.new(token, owner, @params[:identifier], @params[:filepath], file_params).call | |||||
| response = Gitea::Repository::Entries::DeleteService.new(token, owner, @params[:identifier], file_path, file_params).call | |||||
| render_result(response) | render_result(response) | ||||
| rescue Exception => exception | rescue Exception => exception | ||||
| fail!(exception.message) | fail!(exception.message) | ||||
| @@ -45,9 +45,17 @@ module Gitea | |||||
| end | end | ||||
| end | end | ||||
| def file_path | |||||
| if @params[:base64_filepath].present? | |||||
| Base64.decode64(params[:base64_filepath]) | |||||
| else | |||||
| @params[:filepath] | |||||
| end | |||||
| end | |||||
| def valid_params | def valid_params | ||||
| { | { | ||||
| filepath: @params[:filepath], | |||||
| filepath: file_path, | |||||
| sha: @params[:sha] | sha: @params[:sha] | ||||
| } | } | ||||
| end | end | ||||
| @@ -24,7 +24,7 @@ module Gitea | |||||
| def run | def run | ||||
| Contents::UpdateForm.new(valid_params).validate! | Contents::UpdateForm.new(valid_params).validate! | ||||
| response = Gitea::Repository::Entries::UpdateService.new(token, owner, @params[:identifier], @params[:filepath], file_params).call | |||||
| response = Gitea::Repository::Entries::UpdateService.new(token, owner, @params[:identifier], file_path, file_params).call | |||||
| render_result(response) | render_result(response) | ||||
| rescue Exception => exception | rescue Exception => exception | ||||
| fail!(exception.message) | fail!(exception.message) | ||||
| @@ -45,9 +45,25 @@ module Gitea | |||||
| end | end | ||||
| end | end | ||||
| def file_path | |||||
| if @params[:base64_filepath].present? | |||||
| Base64.decode64(params[:base64_filepath]) | |||||
| else | |||||
| @params[:filepath] | |||||
| end | |||||
| end | |||||
| def from_file_path | |||||
| if @params[:base64_from_path].present? | |||||
| Base64.decode64(params[:base64_from_path]) | |||||
| else | |||||
| @params[:from_path] | |||||
| end | |||||
| end | |||||
| def valid_params | def valid_params | ||||
| { | { | ||||
| filepath: @params[:filepath], | |||||
| filepath: file_path, | |||||
| branch: @params[:branch], | branch: @params[:branch], | ||||
| new_branch: @params[:new_branch], | new_branch: @params[:new_branch], | ||||
| sha: @params[:sha] | sha: @params[:sha] | ||||
| @@ -59,7 +75,7 @@ module Gitea | |||||
| branch: @params[:branch], | branch: @params[:branch], | ||||
| sha: @params[:sha], | sha: @params[:sha], | ||||
| new_branch: @params[:new_branch], | new_branch: @params[:new_branch], | ||||
| from_path: @params[:from_path], | |||||
| from_path: from_file_path, | |||||
| message: @params[:message], | message: @params[:message], | ||||
| content: Base64.encode64(@params[:content]) | content: Base64.encode64(@params[:content]) | ||||
| ).compact | ).compact | ||||