新增:entry新增submodule url

This commit is contained in:
yystopf 2023-02-07 14:18:57 +08:00
parent 4bc945028b
commit 39ae14bce7
3 changed files with 11 additions and 1 deletions

View File

@ -197,5 +197,13 @@ module RepositoriesHelper
def tmp_dir def tmp_dir
"repo" "repo"
end end
def repo_git_submodule_url(owner, repo, path)
unless (path.starts_with?('http://') || path.starts_with?('https://'))
path = File.expand_path(path, "#{base_url}/#{owner&.login}/#{repo&.identifier}")
path = path.split("#{Rails.root}/")[1]
end
return path
end
end end

View File

@ -7,6 +7,7 @@ if @project.forge?
json.sha entry['sha'] json.sha entry['sha']
json.path entry['path'] json.path entry['path']
json.type entry['type'] json.type entry['type']
json.submodule_git_url repo_git_submodule_url(@owner, @repository, entry['submodule_git_url'])
json.size entry['size'] json.size entry['size']
is_readme = is_readme?(entry['type'], entry['name']) is_readme = is_readme?(entry['type'], entry['name'])
if is_readme if is_readme

View File

@ -51,6 +51,7 @@ if @project.forge?
json.path entry['path'] json.path entry['path']
json.sha entry['sha'] json.sha entry['sha']
json.type entry['type'] json.type entry['type']
json.submodule_git_url repo_git_submodule_url(@owner, @repository, entry['submodule_git_url'])
json.size entry['size'] json.size entry['size']
json.is_readme_file is_readme?(entry['type'], entry['name']) json.is_readme_file is_readme?(entry['type'], entry['name'])
json.content decode64_content(entry, @owner, @repository, @ref, @path) json.content decode64_content(entry, @owner, @repository, @ref, @path)