mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
新增:恢复分支接口
新增:删除者信息
This commit is contained in:
@@ -18,7 +18,6 @@ class Api::V1::Projects::Branches::ListService < ApplicationService
|
||||
load_default_branch
|
||||
|
||||
@gitea_data[:default_branch] = @gitea_repo_data["default_branch"]
|
||||
|
||||
@gitea_data
|
||||
end
|
||||
|
||||
|
||||
47
app/services/api/v1/projects/branches/restore_service.rb
Normal file
47
app/services/api/v1/projects/branches/restore_service.rb
Normal file
@@ -0,0 +1,47 @@
|
||||
class Api::V1::Projects::Branches::RestoreService < ApplicationService
|
||||
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :project, :token, :owner, :repo, :branch_id, :branch_name
|
||||
attr_accessor :gitea_data
|
||||
|
||||
validates :branch_id, :branch_name, presence: true
|
||||
|
||||
def initialize(project, branch_id, branch_name, token= nil)
|
||||
@project = project
|
||||
@owner = project&.owner&.login
|
||||
@repo = project&.identifier
|
||||
@branch_id = branch_id
|
||||
@branch_name = branch_name
|
||||
@token = token
|
||||
end
|
||||
|
||||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
excute_data_to_gitea
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def request_body
|
||||
{
|
||||
branch_id: branch_id,
|
||||
name: branch_name,
|
||||
}
|
||||
end
|
||||
|
||||
def excute_data_to_gitea
|
||||
begin
|
||||
@gitea_data = $gitea_hat_client.post_repos_branches_restore_by_owner_repo(owner, repo, {query: request_params, body: request_body.to_json})
|
||||
rescue => e
|
||||
raise Error, '恢复分支失败!'
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user