Merge pull request '代码提交信息通过gitea_uid来匹配平台用户' (#132) from yystopf/forgeplus:hotfix_comiter into develop

This commit is contained in:
jasder 2021-09-01 18:59:36 +08:00
commit 40c6425aee
4 changed files with 10 additions and 7 deletions

View File

@ -434,6 +434,10 @@ module ApplicationHelper
User.find_by_login login User.find_by_login login
end end
def find_user_by_gitea_uid(gitea_uid)
User.find_by(gitea_uid: gitea_uid)
end
def render_base64_decoded(str) def render_base64_decoded(str)
return nil if str.blank? return nil if str.blank?
Base64.decode64 str Base64.decode64 str

View File

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

View File

@ -26,9 +26,9 @@ if @project.forge?
end end
json.author do 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 end
json.committer do 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
end end

View File

@ -9,9 +9,7 @@ else
forge_user = forge_user =
if commiter.present? if commiter.present?
User.simple_select.find_by(mail: commiter['email']) User.simple_select.find_by(gitea_uid: commiter['id'])
else
User.simple_select.find_by(mail: commit['commit']['committer']['email'])
end end
json.sha commit['sha'] json.sha commit['sha']