Update create pull request api for gitea platform

This commit is contained in:
Jasder 2020-06-28 18:09:44 +08:00
parent 13a2271ef2
commit 9817c297a9
1 changed files with 27 additions and 12 deletions

View File

@ -1,16 +1,33 @@
class Gitea::PullRequest::CreateService < Gitea::ClientService
attr_reader :token, :user, :repo, :params
# params ex:
# {
# title: 'pull request title',
# body: 'pull request content',
# head: 'develop', // from branch 源分支
# base: 'master' // to branch 目标分支
# }
# 以上列子说明从develop分支合并到master分支
# repo: 仓库名称
# 同一个项目下发送pr例子如下
# 参数说明:
# user: 项目拥有者
# repo 项目名称
# params:
# {
# title: 'pull request title',
# body: 'pull request content',
# head: 'develop', // from branch 源分支, 格式branch
# base: 'master' // to branch 目标分支
# }
# 以上列子说明从develop分支合并到master分支
# Gitea::PullRequest::CreateService.call('token', '项目拥有者', '项目名称', params)
# fork的项目向源项目发送pr例子如下
# 参数说明:
# user源项目拥有者
# repo源项目仓库名称
# params:
# {
# "base": "develop", // to branch 目标分支
# "head": "jasder:master", // from branch 源分支格式username:branch
# "body": "像源项目发送pr",
# "title": "jasder用户向源项目发送pr"
# }
# 以上例子说明jasder用户fork的项目master分支向源项目的develop分支发送pr
# Gitea::PullRequest::CreateService.call('token', '源项目拥有者', '源项目名称', params)
def initialize(token, user, repo, params={})
@token = token
@user = user
@ -19,13 +36,11 @@ class Gitea::PullRequest::CreateService < Gitea::ClientService
end
def call
Rails.logger.info("######_____pr_url______#########{url}")
post(url, request_params)
end
private
def url
"/repos/#{@user.login}/#{@repo}/pulls".freeze
end