mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 20:00:49 +08:00
init project
This commit is contained in:
34
app/services/gitea/pull_request/create_service.rb
Normal file
34
app/services/gitea/pull_request/create_service.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
class Gitea::PullRequest::CreateService < Gitea::ClientService
|
||||
attr_reader :user, :repo, :params
|
||||
|
||||
# params ex:
|
||||
# {
|
||||
# title: 'pull request title',
|
||||
# body: 'pull request content',
|
||||
# head: 'develop', // from branch 源分支
|
||||
# base: 'master' // to branch 目标分支
|
||||
# }
|
||||
# 以上列子说明从develop分支合并到master分支
|
||||
# repo: 仓库名称
|
||||
def initialize(user, repo, params={})
|
||||
@user = user
|
||||
@repo = repo
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
post(url, request_params)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
def url
|
||||
"/repos/#{@user.login}/#{@repo}/pulls".freeze
|
||||
end
|
||||
|
||||
def request_params
|
||||
Hash.new.merge(token: @user.gitea_token, data: @params)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user