add: branch commiter user info

This commit is contained in:
yystopf 2021-09-14 10:59:01 +08:00
parent af7488505d
commit 333d6a8ea4
3 changed files with 19 additions and 7 deletions

View File

@ -26,9 +26,13 @@ module RepositoriesHelper
end end
def render_commit_author(author_json) def render_commit_author(author_json)
return nil if author_json.blank? || author_json["id"].blank? return nil if author_json.blank? || (author_json["id"].blank? && author_json['name'].blank?)
# find_user_by_login author_json['name'] if author_json["id"].present?
find_user_by_gitea_uid author_json['id'] return find_user_by_gitea_uid author_json['id']
end
if author_json["id"].nil? && author_json["name"].present?
return find_user_by_login author_json['name']
end
end end
def readme_render_decode64_content(str, path) def readme_render_decode64_content(str, path)

View File

@ -11,7 +11,11 @@ json.array! @branches do |branch|
json.message branch['commit']['message'] json.message branch['commit']['message']
json.timestamp render_unix_time(branch['commit']['timestamp']) json.timestamp render_unix_time(branch['commit']['timestamp'])
json.time_from_now time_from_now(branch['commit']['timestamp']) json.time_from_now time_from_now(branch['commit']['timestamp'])
json.author branch['commit']['author'] json.author do
json.committer branch['commit']['committer'] json.partial! 'repositories/commit_author', user: render_commit_author(branch['commit']['author']), name: branch['commit']['author']['name']
end
json.committer do
json.partial! 'repositories/commit_author', user: render_commit_author(branch['commit']['committer']), name: branch['commit']['committer']['name']
end
end end
end end

View File

@ -13,8 +13,12 @@ json.array! @branches_slice do |branch_slice|
json.message branch['commit']['message'] json.message branch['commit']['message']
json.timestamp render_unix_time(branch['commit']['timestamp']) json.timestamp render_unix_time(branch['commit']['timestamp'])
json.time_from_now time_from_now(branch['commit']['timestamp']) json.time_from_now time_from_now(branch['commit']['timestamp'])
json.author branch['commit']['author'] json.author do
json.committer branch['commit']['committer'] json.partial! 'repositories/commit_author', user: render_commit_author(branch['commit']['author']), name: branch['commit']['author']['name']
end
json.committer do
json.partial! 'repositories/commit_author', user: render_commit_author(branch['commit']['committer']), name: branch['commit']['committer']['name']
end
end end
end end
end end