新增:恢复分支接口

新增:删除者信息
This commit is contained in:
2023-12-26 08:41:39 +08:00
parent c94bffd844
commit d8eeb8f1b7
5 changed files with 69 additions and 3 deletions

View File

@@ -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

View 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