新增:最新提交加入clone地址
This commit is contained in:
parent
15b8f1e068
commit
2d264bf52b
|
@ -11,6 +11,9 @@ class Api::V1::Projects::CommitsController < Api::V1::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def recent
|
def recent
|
||||||
@result_object = Api::V1::Projects::Commits::RecentService.call(@project, {keyword: params[:keyword], page: page, limit: limit}, current_user&.gitea_token)
|
hash = Api::V1::Projects::Commits::RecentService.call(@project, {keyword: params[:keyword], page: page, limit: limit}, current_user&.gitea_token)
|
||||||
|
@result_object = hash[:result]
|
||||||
|
@object_detail = hash[:detail]
|
||||||
|
puts @object_detail
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,7 +1,7 @@
|
||||||
class Api::V1::Projects::Commits::RecentService < ApplicationService
|
class Api::V1::Projects::Commits::RecentService < ApplicationService
|
||||||
|
|
||||||
attr_reader :project, :page, :limit, :keyword, :owner, :repo, :token
|
attr_reader :project, :page, :limit, :keyword, :owner, :repo, :token
|
||||||
attr_accessor :gitea_data
|
attr_accessor :gitea_data, :gitea_repo_detail
|
||||||
|
|
||||||
def initialize(project, params, token=nil)
|
def initialize(project, params, token=nil)
|
||||||
@project = project
|
@project = project
|
||||||
|
@ -15,8 +15,9 @@ class Api::V1::Projects::Commits::RecentService < ApplicationService
|
||||||
|
|
||||||
def call
|
def call
|
||||||
load_gitea_data
|
load_gitea_data
|
||||||
|
load_gitea_repo_detail
|
||||||
|
|
||||||
gitea_data
|
{result: gitea_data, detail:gitea_repo_detail}
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -36,4 +37,8 @@ class Api::V1::Projects::Commits::RecentService < ApplicationService
|
||||||
raise Error, "获取最近提交列表失败" unless @gitea_data.is_a?(Hash)
|
raise Error, "获取最近提交列表失败" unless @gitea_data.is_a?(Hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def load_gitea_repo_detail
|
||||||
|
@gitea_repo_detail = $gitea_client.get_repos_by_owner_repo(owner, repo, {query: {access_token: token}})
|
||||||
|
raise Error, "获取项目详情失败" unless @gitea_repo_detail.is_a?(Hash)
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -1,4 +1,6 @@
|
||||||
json.total_count @result_object[:total_data].to_i
|
json.total_count @result_object[:total_data].to_i
|
||||||
|
json.ssh_url @object_detail['ssh_url']
|
||||||
|
json.clone_url @object_detail['clone_url']
|
||||||
json.commits @result_object[:data].each do |commit|
|
json.commits @result_object[:data].each do |commit|
|
||||||
json.sha commit['sha']
|
json.sha commit['sha']
|
||||||
json.author do
|
json.author do
|
||||||
|
|
Loading…
Reference in New Issue