Update get repo entries dir api

This commit is contained in:
Jasder
2020-06-03 11:21:43 +08:00
parent 9f9cec34b6
commit 96ed75f6b0
3 changed files with 34 additions and 25 deletions

View File

@@ -0,0 +1,16 @@
json.commit do
json.sha commit['sha']
json.url EduSetting.get('host_name') + commit_repository_path(project.repository, commit['sha'])
json.message commit['commit']['message']
json.author commit['commit']['author']
json.committer commit['commit']['committer']
json.timestamp render_unix_time(commit['commit']['committer']['date'])
json.time_from_now time_from_now(commit['commit']['committer']['date'])
end
json.author do
json.partial! 'commit_author', user: render_commit_author(commit['author'])
end
json.committer do
json.partial! 'commit_author', user: render_commit_author(commit['committer'])
end

View File

@@ -1,23 +1,12 @@
json.array! @entries do |entry|
# json.name entry['name']
# json.path entry['path']
# json.sha entry['sha']
# json.type entry['type']
# json.size entry['size']
# json.content entry['content']
# json.target entry['target']
# json.commit entry['commit']
if entry['name'] == "README.md"
readme_md = Gitea::Repository::Entries::GetService.new(@project.owner, @project.identifier, entry['path'], ref:@ref).call
json.name readme_md['name']
json.path readme_md['path']
json.sha readme_md['sha']
json.type readme_md['type']
json.size readme_md['size']
json.content readme_md['content'].present? ? render_decode64_content(readme_md['content']).force_encoding('UTF-8') : ""
json.target readme_md['target']
json.last_commit do
if @latest_commit
json.partial! 'commit', commit: @latest_commit, project: @project
else
json.nil!
end
end
json.entries do
json.array! @entries do |entry|
json.name entry['name']
json.path entry['path']
json.sha entry['sha']
@@ -25,9 +14,8 @@ json.array! @entries do |entry|
json.size entry['size']
json.content entry['content']
json.target entry['target']
end
if entry['latest_commit']
json.partial! 'last_commit', entry: entry
if entry['latest_commit']
json.partial! 'last_commit', entry: entry
end
end
end