Browse Source

add: branch commiter user info

tags/v3.2.0
yystopf 4 years ago
parent
commit
333d6a8ea4
3 changed files with 19 additions and 7 deletions
  1. +7
    -3
      app/helpers/repositories_helper.rb
  2. +6
    -2
      app/views/projects/branches.json.jbuilder
  3. +6
    -2
      app/views/projects/branches_slice.json.jbuilder

+ 7
- 3
app/helpers/repositories_helper.rb 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?
# 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 end
def readme_render_decode64_content(str, path) def readme_render_decode64_content(str, path)


+ 6
- 2
app/views/projects/branches.json.jbuilder 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.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 end

+ 6
- 2
app/views/projects/branches_slice.json.jbuilder 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.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 end
end end

Loading…
Cancel
Save