Merge pull request '同步代码' (#288) from develop into standalone_develop
This commit is contained in:
commit
d48700d200
|
@ -16,13 +16,13 @@ class ProjectsController < ApplicationController
|
|||
menu.append(menu_hash_by_name("home"))
|
||||
menu.append(menu_hash_by_name("code")) if @project.has_menu_permission("code")
|
||||
menu.append(menu_hash_by_name("issues")) if @project.has_menu_permission("issues")
|
||||
menu.append(menu_hash_by_name("pulls")) if @project.has_menu_permission("pulls")
|
||||
menu.append(menu_hash_by_name("wiki")) if @project.has_menu_permission("wiki")
|
||||
menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops")
|
||||
menu.append(menu_hash_by_name("pulls")) if @project.has_menu_permission("pulls") && @project.forge?
|
||||
menu.append(menu_hash_by_name("wiki")) if @project.has_menu_permission("wiki") && @project.forge?
|
||||
menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops") && @project.forge?
|
||||
menu.append(menu_hash_by_name("versions")) if @project.has_menu_permission("versions")
|
||||
menu.append(menu_hash_by_name("resources")) if @project.has_menu_permission("resources")
|
||||
menu.append(menu_hash_by_name("resources")) if @project.has_menu_permission("resources") && @project.forge?
|
||||
menu.append(menu_hash_by_name("activity"))
|
||||
menu.append(menu_hash_by_name("settings")) if current_user.admin? || @project.manager?(current_user)
|
||||
menu.append(menu_hash_by_name("settings")) if (current_user.admin? || @project.manager?(current_user)) && @project.forge?
|
||||
|
||||
render json: menu
|
||||
end
|
||||
|
|
|
@ -71,16 +71,32 @@ class RepositoriesController < ApplicationController
|
|||
logger.info "######### sub_entries: #{@sub_entries}"
|
||||
return render_error('该文件暂未开放,敬请期待.') if @sub_entries['status'].to_i === -1
|
||||
|
||||
tmp_entries = [{
|
||||
tmp_entries = {
|
||||
"content" => @sub_entries['data']['content'],
|
||||
"type" => "blob"
|
||||
}]
|
||||
}
|
||||
@sub_entries = {
|
||||
"trees"=>tmp_entries,
|
||||
"commits" => [{}]
|
||||
}
|
||||
else
|
||||
@sub_entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder&.repo_name, {path: file_path_uri})
|
||||
begin
|
||||
@sub_entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder&.repo_name, {path: file_path_uri})
|
||||
if @sub_entries.blank? || @sub_entries['status'].to_i === -1
|
||||
@sub_entries = Educoder::Repository::Entries::GetService.call(@project&.project_educoder&.repo_name, file_path_uri)
|
||||
return render_error('该文件暂未开放,敬请期待.') if @sub_entries['status'].to_i === -1
|
||||
tmp_entries = {
|
||||
"content" => @sub_entries['data']['content'],
|
||||
"type" => "blob"
|
||||
}
|
||||
@sub_entries = {
|
||||
"trees"=>tmp_entries,
|
||||
"commits" => [{}]
|
||||
}
|
||||
end
|
||||
rescue
|
||||
return render_error('该文件暂未开放,敬请期待.')
|
||||
end
|
||||
end
|
||||
else
|
||||
@path = Gitea.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/"
|
||||
|
@ -117,8 +133,7 @@ class RepositoriesController < ApplicationController
|
|||
def commit
|
||||
@sha = params[:sha]
|
||||
if @project.educoder?
|
||||
@commit = {}
|
||||
@commit_diff ={}
|
||||
return render_error('暂未开放,敬请期待.')
|
||||
else
|
||||
@commit = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, current_user&.gitea_token)
|
||||
@commit_diff = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, current_user&.gitea_token, {diff: true})
|
||||
|
|
|
@ -26,8 +26,12 @@ module TagChosenHelper
|
|||
end
|
||||
|
||||
def render_branches(project)
|
||||
branches = Gitea::Repository::Branches::ListService.call(project&.owner, project.identifier)
|
||||
branches.collect{|i| i["name"] if i.is_a?(Hash)}
|
||||
if project.educoder?
|
||||
return ['master']
|
||||
else
|
||||
branches = Gitea::Repository::Branches::ListService.call(project&.owner, project.identifier)
|
||||
branches.collect{|i| i["name"] if i.is_a?(Hash)}
|
||||
end
|
||||
end
|
||||
|
||||
def render_cache_trackers
|
||||
|
|
|
@ -7,11 +7,22 @@ if @project.educoder?
|
|||
json.timestamp 0
|
||||
json.time_from_now commit[0]['time']
|
||||
end
|
||||
json.author do
|
||||
{}
|
||||
# json.partial! '/projects/author', user: render_commit_author(commit['author'])
|
||||
end
|
||||
json.committer {}
|
||||
if commit[0]['author'].present?
|
||||
json.author do
|
||||
json.id nil
|
||||
json.login commit[0]['author']['username']
|
||||
json.name commit[0]['author']['username']
|
||||
json.type nil
|
||||
json.image_url commit[0]['author']['image_url']
|
||||
end
|
||||
json.committer do
|
||||
json.id nil
|
||||
json.login commit[0]['author']['username']
|
||||
json.name commit[0]['author']['username']
|
||||
json.type nil
|
||||
json.image_url commit[0]['author']['image_url']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if @project.forge?
|
||||
|
|
|
@ -32,6 +32,8 @@ end
|
|||
|
||||
if @project.educoder?
|
||||
file_path = params[:filepath].present? ? [params[:filepath], entry['name']].join('/') : entry['name']
|
||||
file_type = File.extname(entry['name'].to_s)[1..-1]
|
||||
image_type = image_type?(file_type)
|
||||
|
||||
json.name entry['name']
|
||||
json.sha nil
|
||||
|
@ -42,7 +44,7 @@ if @project.educoder?
|
|||
json.target nil
|
||||
json.download_url nil
|
||||
json.direct_download false
|
||||
json.image_type false
|
||||
json.image_type image_type
|
||||
json.is_readme_file false
|
||||
json.commit do
|
||||
json.message entry['title']
|
||||
|
|
|
@ -12,7 +12,7 @@ if @hash_commit.blank? || @project.educoder? #如果有状态值,则表示
|
|||
json.type nil
|
||||
json.image_url commit['author']['image_url']
|
||||
end
|
||||
json.commiter do
|
||||
json.committer do
|
||||
json.id nil
|
||||
json.login commit['author']['username']
|
||||
json.name commit['author']['username']
|
||||
|
|
|
@ -24,8 +24,12 @@ if @project.educoder?
|
|||
end
|
||||
end
|
||||
json.entries do
|
||||
json.array! @sub_entries['trees'] do |entry|
|
||||
json.partial! 'repositories/simple_entry', locals: { entry: entry }
|
||||
if @sub_entries['trees'].is_a?(Array)
|
||||
json.array! @sub_entries['trees'] do |entry|
|
||||
json.partial! 'repositories/simple_entry', locals: { entry: entry }
|
||||
end
|
||||
elsif @sub_entries['trees'].is_a?(Hash)
|
||||
json.partial! 'repositories/simple_entry', locals: { entry: @sub_entries['trees'] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue