Merge branch 'dev_trustie' into dev_chain

This commit is contained in:
sylor_huang@126.com 2020-07-03 16:13:24 +08:00
commit 21417ad300
1 changed files with 8 additions and 5 deletions

View File

@ -9,6 +9,7 @@ class RepositoriesController < ApplicationController
before_action :authorizate_user_can_edit_repo!, only: %i[sync_mirror]
before_action :get_ref, only: %i[entries sub_entries top_counts]
before_action :get_statistics, only: %i[top_counts]
before_action :get_latest_commit, %i[entries sub_entries top_counts]
def show
@user = current_user
@ -126,7 +127,7 @@ class RepositoriesController < ApplicationController
end
# TODO 获取最新commit信息
def get_latest_commit
def project_commits
Gitea::Repository::Commits::ListService.new(@project.owner.login, @project.identifier,
sha: get_ref, page: 1, limit: 1, token: current_user&.gitea_token).call
end
@ -134,16 +135,18 @@ class RepositoriesController < ApplicationController
def get_statistics
@branches_count = Gitea::Repository::Branches::ListService.new(@project.owner, @project.identifier).call&.size
@tags_count = Gitea::Repository::Tags::ListService.new(current_user&.gitea_token, @project.owner.login, @project.identifier).call&.size
latest_commit = get_latest_commit
@latest_commit = latest_commit[:body][0] if latest_commit.present?
@commits_count = latest_commit[:total_count] if latest_commit.present?
end
def get_ref
@ref = params[:ref] || "master"
end
def get_latest_commit
latest_commit = project_commits
@latest_commit = latest_commit[:body][0] if latest_commit.present?
@commits_count = latest_commit[:total_count] if latest_commit.present?
end
def content_params
{
filepath: params[:filepath],