mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-20 11:45:57 +08:00
ADD get a commit api
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
# Get a single commit from a repository
|
||||
class Gitea::Repository::Commits::GetService < Gitea::ClientService
|
||||
attr_reader :token, :owner, :repo, :sha, :custom
|
||||
attr_reader :token, :owner, :repo, :sha, :hash
|
||||
|
||||
# sha: the commit hash
|
||||
# ex: Gitea::Repository::Commits::GetService.new(@repo.user.login, repo.identifier, params[:sha], current_user.gitea_token)
|
||||
# TODO custom参数用于判断调用哪个api
|
||||
def initialize(owner, repo, sha, token, custom=false)
|
||||
def initialize(owner, repo, sha, token, hash={})
|
||||
@token = token
|
||||
@owner = owner
|
||||
@sha = sha
|
||||
@repo = repo
|
||||
@custom = custom
|
||||
@hash = hash
|
||||
end
|
||||
|
||||
def call
|
||||
@@ -24,10 +24,10 @@ class Gitea::Repository::Commits::GetService < Gitea::ClientService
|
||||
end
|
||||
|
||||
def url
|
||||
if custom
|
||||
if hash[:diff]
|
||||
# TODO
|
||||
# 平台自己编写的gitea接口,后续可能会通过提交pr的形式合并到gitea原有的接口上
|
||||
"/repos/#{owner}/#{repo}/commits/diff/#{sha}".freeze
|
||||
"/repos/#{owner}/#{repo}/commits/#{sha}/diff".freeze
|
||||
else
|
||||
"/repos/#{owner}/#{repo}/git/commits/#{sha}".freeze
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user