mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
Update get repo entries dir api
This commit is contained in:
16
app/views/repositories/_commit.json.jbuilder
Normal file
16
app/views/repositories/_commit.json.jbuilder
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user