diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 7057ac581..d9679cb80 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -26,9 +26,13 @@ module RepositoriesHelper end def render_commit_author(author_json) - return nil if author_json.blank? || author_json["id"].blank? - # find_user_by_login author_json['name'] - find_user_by_gitea_uid author_json['id'] + return nil if author_json.blank? || (author_json["id"].blank? && author_json['name'].blank?) + if author_json["id"].present? + 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 def readme_render_decode64_content(str, path) diff --git a/app/views/projects/branches.json.jbuilder b/app/views/projects/branches.json.jbuilder index dd722c9d9..ad4f4328a 100644 --- a/app/views/projects/branches.json.jbuilder +++ b/app/views/projects/branches.json.jbuilder @@ -11,7 +11,11 @@ json.array! @branches do |branch| json.message branch['commit']['message'] json.timestamp render_unix_time(branch['commit']['timestamp']) json.time_from_now time_from_now(branch['commit']['timestamp']) - json.author branch['commit']['author'] - json.committer branch['commit']['committer'] + json.author do + 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 diff --git a/app/views/projects/branches_slice.json.jbuilder b/app/views/projects/branches_slice.json.jbuilder index 2731b1513..31c662a13 100644 --- a/app/views/projects/branches_slice.json.jbuilder +++ b/app/views/projects/branches_slice.json.jbuilder @@ -13,8 +13,12 @@ json.array! @branches_slice do |branch_slice| json.message branch['commit']['message'] json.timestamp render_unix_time(branch['commit']['timestamp']) json.time_from_now time_from_now(branch['commit']['timestamp']) - json.author branch['commit']['author'] - json.committer branch['commit']['committer'] + json.author do + 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 \ No newline at end of file