diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index d9ac3746f..d05d54611 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -197,5 +197,13 @@ module RepositoriesHelper def tmp_dir "repo" 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 diff --git a/app/views/repositories/_simple_entry.json.jbuilder b/app/views/repositories/_simple_entry.json.jbuilder index 30ed9d22d..013b33a9d 100644 --- a/app/views/repositories/_simple_entry.json.jbuilder +++ b/app/views/repositories/_simple_entry.json.jbuilder @@ -7,6 +7,7 @@ if @project.forge? json.sha entry['sha'] json.path entry['path'] json.type entry['type'] + json.submodule_git_url repo_git_submodule_url(@owner, @repository, entry['submodule_git_url']) json.size entry['size'] is_readme = is_readme?(entry['type'], entry['name']) if is_readme diff --git a/app/views/repositories/entries.json.jbuilder b/app/views/repositories/entries.json.jbuilder index 6dea93b32..310918597 100644 --- a/app/views/repositories/entries.json.jbuilder +++ b/app/views/repositories/entries.json.jbuilder @@ -51,6 +51,7 @@ if @project.forge? json.path entry['path'] json.sha entry['sha'] json.type entry['type'] + json.submodule_git_url repo_git_submodule_url(@owner, @repository, entry['submodule_git_url']) json.size entry['size'] json.is_readme_file is_readme?(entry['type'], entry['name']) json.content decode64_content(entry, @owner, @repository, @ref, @path)