Merge branch 'dev_trustie' of http://gitea.trustie.net/jasder/forgeplus into dev_trustie
This commit is contained in:
commit
8b21ed18b8
|
@ -1632,6 +1632,8 @@ http://localhost:3000/api/repositories/5845/commits/b0c4a4a1487d53acebf2addc544b
|
||||||
|-- IsCreated |boolean|是否为新添加的文件,true:是; false:否|
|
|-- IsCreated |boolean|是否为新添加的文件,true:是; false:否|
|
||||||
|-- IsDeleted |boolean|是否为删除的文件,true:是;false:否|
|
|-- IsDeleted |boolean|是否为删除的文件,true:是;false:否|
|
||||||
|-- IsRenamed |boolean|是否为重命名的文件,true:是,false:否|
|
|-- IsRenamed |boolean|是否为重命名的文件,true:是,false:否|
|
||||||
|
|-- IsBin |boolean|是否为二进制文件,true:是,false:否|
|
||||||
|
|-- IsLFSFile |boolean|是否git lfs操作的大文件,true:是,false:否|
|
||||||
|-- IsSubmodule |boolean|收否为子模块,true:是;false:否|
|
|-- IsSubmodule |boolean|收否为子模块,true:是;false:否|
|
||||||
|-- Sections |array| |
|
|-- Sections |array| |
|
||||||
|---- Name |string|文件名称|
|
|---- Name |string|文件名称|
|
||||||
|
|
|
@ -10,7 +10,8 @@ class RepositoriesController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@branches_count = Gitea::Repository::BranchesService.new(@project.owner, @project.identifier).call&.size
|
@branches_count = Gitea::Repository::BranchesService.new(@project.owner, @project.identifier).call&.size
|
||||||
@commits_count = Gitea::Repository::Commits::ListService.new(@project.owner, @project.identifier).call[:total_count]
|
@commits_count = Gitea::Repository::Commits::ListService.new(@project.owner.login, @project.identifier,
|
||||||
|
sha: params[:sha], page: params[:page], limit: params[:limit], token: current_user&.gitea_token).call[:total_count]
|
||||||
@tags_count = Gitea::Repository::Tags::ListService.new(current_user&.gitea_token, @project.owner.login, @project.identifier).call&.size
|
@tags_count = Gitea::Repository::Tags::ListService.new(current_user&.gitea_token, @project.owner.login, @project.identifier).call&.size
|
||||||
@result = Gitea::Repository::GetService.new(@project.owner, @project.identifier).call
|
@result = Gitea::Repository::GetService.new(@project.owner, @project.identifier).call
|
||||||
@project_fork_id = @project.try(:forked_from_project_id)
|
@project_fork_id = @project.try(:forked_from_project_id)
|
||||||
|
@ -44,12 +45,12 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def commits
|
def commits
|
||||||
@hash_commit = Gitea::Repository::Commits::ListService.new(@project.owner, @project.identifier, sha: params[:sha], page: params[:page]).call
|
@hash_commit = Gitea::Repository::Commits::ListService.new(@project.owner.login, @project.identifier,
|
||||||
|
sha: params[:sha], page: params[:page], limit: params[:limit], token: current_user&.gitea_token).call
|
||||||
end
|
end
|
||||||
|
|
||||||
def commit
|
def commit
|
||||||
@commit = Gitea::Repository::Commits::GetService.new(@repo.user.login, @repo.identifier, params[:sha], current_user.gitea_token).call
|
@commit = Gitea::Repository::Commits::GetService.new(@repo.user.login, @repo.identifier, params[:sha], current_user.gitea_token).call
|
||||||
@custom_commit = Gitea::Repository::Commits::GetService.new(@repo.user.login, @repo.identifier, params[:sha], current_user.gitea_token, true).call
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def tags
|
def tags
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
class Gitea::ClientService < ApplicationService
|
class Gitea::ClientService < ApplicationService
|
||||||
attr_reader :username, :secret, :token, :url, :params
|
attr_reader :username, :secret, :token, :url, :params
|
||||||
|
|
||||||
|
PAGINATE_DEFAULT_PAGE = 1
|
||||||
|
PAGINATE_DEFAULT_LIMIT = 20
|
||||||
|
|
||||||
def initialize(options={})
|
def initialize(options={})
|
||||||
@username = options[:username]
|
@username = options[:username]
|
||||||
@secret = options[:password]
|
@secret = options[:password]
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
# Get a list of all commits from a repository
|
# Get a list of all commits from a repository
|
||||||
class Gitea::Repository::Commits::ListService < Gitea::ClientService
|
class Gitea::Repository::Commits::ListService < Gitea::ClientService
|
||||||
attr_reader :user, :repo_name, :args
|
attr_reader :owner, :repo_name, :args
|
||||||
|
|
||||||
# sha: SHA or branch to start listing commits from (usually 'master')
|
# sha: SHA or branch to start listing commits from (usually 'master')
|
||||||
def initialize(user, repo_name, **args)
|
# ex:
|
||||||
@user = user
|
# Gitea::Repository::Commits::ListService.new(@project.owner.login, @project.identifier,
|
||||||
|
# sha: params[:sha], page: params[:page], limit: params[:limit], token: current_user&.gitea_token).call
|
||||||
|
def initialize(owner, repo_name, **args)
|
||||||
|
@owner = owner
|
||||||
@repo_name = repo_name
|
@repo_name = repo_name
|
||||||
@args = { sha: 'master', page: 1 }.merge(args.compact)
|
@args = args
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
|
@ -16,15 +19,14 @@ class Gitea::Repository::Commits::ListService < Gitea::ClientService
|
||||||
|
|
||||||
private
|
private
|
||||||
def params
|
def params
|
||||||
@args.merge(token: user.gitea_token)
|
{ sha: args[:sha] || 'master', page: args[:page] || PAGINATE_DEFAULT_PAGE, limit: args[:limit] || PAGINATE_DEFAULT_LIMIT, token: args[:token] || "" }
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"/repos/#{user.login}/#{repo_name}/commits".freeze
|
"/repos/#{owner}/#{repo_name}/commits".freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_result(response)
|
def render_result(response)
|
||||||
|
|
||||||
case response.status
|
case response.status
|
||||||
when 200
|
when 200
|
||||||
result = {}
|
result = {}
|
||||||
|
|
|
@ -21,11 +21,11 @@ class Gitea::Repository::Tags::ListService < Gitea::ClientService
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_page
|
def set_page
|
||||||
(params[:page] || 1).to_i
|
(params[:page] || PAGINATE_DEFAULT_PAGE).to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_limit
|
def set_limit
|
||||||
(params[:limit] || 50).to_i
|
(params[:limit] || PAGINATE_DEFAULT_LIMIT).to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
|
|
|
@ -13,7 +13,7 @@ json.array! @branches do |branch|
|
||||||
json.time_from_now time_from_now(branch['commit']['timestamp'])
|
json.time_from_now time_from_now(branch['commit']['timestamp'])
|
||||||
end
|
end
|
||||||
|
|
||||||
user = find_user_by_login_or_mail(branch['commit']['author']['username'])
|
user = find_user_by_login_or_mail(branch['commit']['author']['name'])
|
||||||
json.author do
|
json.author do
|
||||||
if user
|
if user
|
||||||
json.login user.login
|
json.login user.login
|
||||||
|
|
|
@ -4,6 +4,7 @@ json.projects @projects do |project|
|
||||||
next if user.blank?
|
next if user.blank?
|
||||||
|
|
||||||
json.id project.id
|
json.id project.id
|
||||||
|
json.repo_id project&.repository.id
|
||||||
json.identifier project.identifier
|
json.identifier project.identifier
|
||||||
json.name project.name
|
json.name project.name
|
||||||
json.description Nokogiri::HTML(project.description).text
|
json.description Nokogiri::HTML(project.description).text
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
json.key_format! camelize: :lower
|
json.key_format! camelize: :lower
|
||||||
json.additions @custom_commit['TotalAddition']
|
json.additions @commit['commit_diff']['TotalAddition']
|
||||||
json.deletions @custom_commit['TotalDeletion']
|
json.deletions @commit['commit_diff']['TotalDeletion']
|
||||||
json.sha @commit['sha']
|
json.sha @commit['sha']
|
||||||
json.url request.url
|
json.url request.url
|
||||||
json.commit do
|
json.commit do
|
||||||
@commit['commit'].delete('url')
|
@commit['commit'].delete('url')
|
||||||
json.author @commit['commit']['author']
|
json.author @commit['commit']['author']
|
||||||
json.committer @commit['commit']['committer']
|
json.committer @commit['commit']['committer']
|
||||||
|
json.message @commit['commit']['message']
|
||||||
json.tree do
|
json.tree do
|
||||||
@commit['commit']['tree']['sha']
|
@commit['commit']['tree']['sha']
|
||||||
end
|
end
|
||||||
|
@ -23,4 +24,4 @@ json.parents @commit['parents'] do |parent|
|
||||||
json.url EduSetting.get('host_name') + commit_repository_path(@repo, parent['sha'])
|
json.url EduSetting.get('host_name') + commit_repository_path(@repo, parent['sha'])
|
||||||
end
|
end
|
||||||
|
|
||||||
json.files @custom_commit['Files']
|
json.files @commit['commit_diff']['Files']
|
||||||
|
|
Loading…
Reference in New Issue