From 84e48d25c1b5c0327330f8a2a7d4bb197c6e9713 Mon Sep 17 00:00:00 2001 From: jasder Date: Tue, 20 Apr 2021 18:35:41 +0800 Subject: [PATCH] =?UTF-8?q?FIX=20render=20user=20bug=20with=20=20pull?= =?UTF-8?q?=E2=80=98s=20commits=20and=20repo's=20commits=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/pull_requests/_commit.json.jbuilder | 4 ++-- app/views/repositories/commits.json.jbuilder | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/views/pull_requests/_commit.json.jbuilder b/app/views/pull_requests/_commit.json.jbuilder index 072e53c91..7a9232efe 100644 --- a/app/views/pull_requests/_commit.json.jbuilder +++ b/app/views/pull_requests/_commit.json.jbuilder @@ -1,10 +1,10 @@ json.author do - author = User.find_by(login: commit['Author']['Name']) + author = User.find_by(mail: commit['Author']['Email']) json.partial! 'repositories/commit_author', locals: { user: author, name: commit['Committer']['Name'] } end json.committer do - author = User.find_by(login: commit['Committer']['Name']) + author = User.find_by(mail: commit['Committer']['Email']) json.partial! 'repositories/commit_author', locals: { user: author, name: commit['Committer']['Name'] } end json.timestamp render_unix_time(commit['Committer']['When']) diff --git a/app/views/repositories/commits.json.jbuilder b/app/views/repositories/commits.json.jbuilder index 82cd17133..d123daf54 100644 --- a/app/views/repositories/commits.json.jbuilder +++ b/app/views/repositories/commits.json.jbuilder @@ -5,12 +5,15 @@ else json.total_count @hash_commit[:total_count] json.commits do json.array! @hash_commit[:body] do |commit| - json.commit1 commit commiter = commit['committer'] - if commiter.present? - commit_user_id = commiter['id'] - forge_user = User.simple_select.find_by(gitea_uid: commit_user_id) - end + + forge_user = + if commiter.present? + User.simple_select.find_by(mail: commiter['email']) + else + User.simple_select.find_by(mail: commit['commit']['committer']['email']) + end + json.sha commit['sha'] json.message commit['commit']['message'] json.timestamp render_unix_time(commit['commit']['author']['date'])