Merge branch 'develop' into standalone_develop
This commit is contained in:
commit
fae8313df6
|
@ -56,7 +56,7 @@ class PullRequestsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
return normal_status(-1, "您不是目标分支开发者,没有权限,请联系目标分支作者.") unless @project.operator?(current_user)
|
# return normal_status(-1, "您不是目标分支开发者,没有权限,请联系目标分支作者.") unless @project.operator?(current_user)
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
@pull_request, @gitea_pull_request = PullRequests::CreateService.call(current_user, @owner, @project, params)
|
@pull_request, @gitea_pull_request = PullRequests::CreateService.call(current_user, @owner, @project, params)
|
||||||
if @gitea_pull_request[:status] == :success
|
if @gitea_pull_request[:status] == :success
|
||||||
|
|
|
@ -45,7 +45,7 @@ module RepositoriesHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def readme_render_decode64_content(str, path)
|
def readme_render_decode64_content(str, owner, repo, ref)
|
||||||
return nil if str.blank?
|
return nil if str.blank?
|
||||||
begin
|
begin
|
||||||
content = Base64.decode64(str).force_encoding('UTF-8')
|
content = Base64.decode64(str).force_encoding('UTF-8')
|
||||||
|
@ -63,13 +63,14 @@ module RepositoriesHelper
|
||||||
if remove_title.length > 0
|
if remove_title.length > 0
|
||||||
r_content = r_content.gsub(/#{remove_title[0]}/, "").strip
|
r_content = r_content.gsub(/#{remove_title[0]}/, "").strip
|
||||||
end
|
end
|
||||||
if r_content.include?("?")
|
# if r_content.include?("?")
|
||||||
new_r_content = r_content + "&raw=true"
|
# new_r_content = r_content + "&raw=true"
|
||||||
else
|
# else
|
||||||
new_r_content = r_content + "?raw=true"
|
# new_r_content = r_content + "?raw=true"
|
||||||
end
|
# end
|
||||||
unless r_content.include?("http://") || r_content.include?("https://") || r_content.include?("mailto:")
|
unless r_content.include?("http://") || r_content.include?("https://") || r_content.include?("mailto:")
|
||||||
new_r_content = "#{path}" + new_r_content
|
# new_r_content = "#{path}" + new_r_content
|
||||||
|
new_r_content = [base_url, "/api/#{owner&.login}/#{repo.identifier}/raw?filepath=#{r_content}&ref=#{ref}"].join
|
||||||
end
|
end
|
||||||
content = content.gsub(/#{r_content}/, new_r_content)
|
content = content.gsub(/#{r_content}/, new_r_content)
|
||||||
end
|
end
|
||||||
|
@ -94,7 +95,7 @@ module RepositoriesHelper
|
||||||
def decode64_content(entry, owner, repo, ref, path=nil)
|
def decode64_content(entry, owner, repo, ref, path=nil)
|
||||||
if is_readme?(entry['type'], entry['name'])
|
if is_readme?(entry['type'], entry['name'])
|
||||||
content = Gitea::Repository::Entries::GetService.call(owner, repo.identifier, URI.escape(entry['path']), ref: ref)['content']
|
content = Gitea::Repository::Entries::GetService.call(owner, repo.identifier, URI.escape(entry['path']), ref: ref)['content']
|
||||||
readme_render_decode64_content(content, path)
|
readme_render_decode64_content(content, owner, repo, ref)
|
||||||
else
|
else
|
||||||
file_type = File.extname(entry['name'].to_s)[1..-1]
|
file_type = File.extname(entry['name'].to_s)[1..-1]
|
||||||
if image_type?(file_type)
|
if image_type?(file_type)
|
||||||
|
|
Loading…
Reference in New Issue