diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a1aea4ae..72f3f341 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -434,6 +434,10 @@ module ApplicationHelper User.find_by_login login end + def find_user_by_gitea_uid(gitea_uid) + User.find_by(gitea_uid: gitea_uid) + end + def render_base64_decoded(str) return nil if str.blank? Base64.decode64 str diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index a7218810..7057ac58 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -26,8 +26,9 @@ module RepositoriesHelper end def render_commit_author(author_json) - return nil if author_json.blank? - find_user_by_login author_json['name'] + 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'] end def readme_render_decode64_content(str, path) diff --git a/app/views/repositories/_commit.json.jbuilder b/app/views/repositories/_commit.json.jbuilder index 95cb0341..3f3dd554 100644 --- a/app/views/repositories/_commit.json.jbuilder +++ b/app/views/repositories/_commit.json.jbuilder @@ -26,9 +26,9 @@ if @project.forge? end json.author do - json.partial! 'commit_author', user: render_commit_author(commit['commit']['author']), name: commit['commit']['author']['name'] + json.partial! 'commit_author', user: render_commit_author(commit['author']), name: commit['commit']['author']['name'] end json.committer do - json.partial! 'commit_author', user: render_commit_author(commit['commit']['committer']), name: commit['commit']['committer']['name'] + json.partial! 'commit_author', user: render_commit_author(commit['committer']), name: commit['commit']['committer']['name'] end end diff --git a/app/views/repositories/commits.json.jbuilder b/app/views/repositories/commits.json.jbuilder index 16744858..9dd90446 100644 --- a/app/views/repositories/commits.json.jbuilder +++ b/app/views/repositories/commits.json.jbuilder @@ -9,9 +9,7 @@ else forge_user = if commiter.present? - User.simple_select.find_by(mail: commiter['email']) - else - User.simple_select.find_by(mail: commit['commit']['committer']['email']) + User.simple_select.find_by(gitea_uid: commiter['id']) end json.sha commit['sha']