Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
b99071f1
H
hub
项目概览
github
/
hub
10 个月 前同步成功
通知
3
Star
22523
Fork
2406
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b99071f1
编写于
3月 29, 2019
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[pull-request] Tweak & test opening a PR as a draft
上级
b207e803
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
43 addition
and
9 deletion
+43
-9
commands/pull_request.go
commands/pull_request.go
+4
-7
features/pull_request.feature
features/pull_request.feature
+32
-0
github/client.go
github/client.go
+1
-1
github/http.go
github/http.go
+6
-1
未找到文件。
commands/pull_request.go
浏览文件 @
b99071f1
...
...
@@ -16,7 +16,7 @@ import (
var
cmdPullRequest
=
&
Command
{
Run
:
pullRequest
,
Usage
:
`
pull-request [-focp
] [-b <BASE>] [-h <HEAD>] [-r <REVIEWERS> ] [-a <ASSIGNEES>] [-M <MILESTONE>] [-l <LABELS>] [--draft
]
pull-request [-focp
d] [-b <BASE>] [-h <HEAD>] [-r <REVIEWERS> ] [-a <ASSIGNEES>] [-M <MILESTONE>] [-l <LABELS>
]
pull-request -m <MESSAGE> [--edit]
pull-request -F <FILE> [--edit]
pull-request -i <ISSUE>
...
...
@@ -312,20 +312,17 @@ of text is the title and the rest is the description.`, fullBase, fullHead))
}
}
draft
:=
args
.
Flag
.
Bool
(
"--draft"
)
var
pullRequestURL
string
if
args
.
Noop
{
args
.
Before
(
fmt
.
Sprintf
(
"Would request a pull request to %s from %s"
,
fullBase
,
fullHead
),
""
)
pullRequestURL
=
"PULL_REQUEST_URL"
}
else
{
params
:=
map
[
string
]
interface
{}{
"base"
:
base
,
"head"
:
fullHead
,
"base"
:
base
,
"head"
:
fullHead
,
"draft"
:
args
.
Flag
.
Bool
(
"--draft"
),
}
params
[
"draft"
]
=
draft
if
title
!=
""
{
params
[
"title"
]
=
title
if
body
!=
""
{
...
...
features/pull_request.feature
浏览文件 @
b99071f1
...
...
@@ -4,6 +4,25 @@ Feature: hub pull-request
And
I am
"mislav"
on github.com with OAuth token
"OTOKEN"
And
the git commit editor is
"vim"
Scenario
:
Basic pull request
Given the GitHub API server
:
"""
post('/repos/mislav/coral/pulls') {
halt 400 unless request.env['HTTP_ACCEPT'] == 'application/vnd.github.shadow-cat-preview+json;charset=utf-8'
halt 400 if (params.keys - %w[title body base head draft issue]).any?
assert :title => 'hello',
:body => nil,
:base => 'master',
:head => 'mislav:master',
:draft => false,
:issue => nil
status 201
json :html_url => "the://url"
}
"""
When
I successfully run `hub pull-request -m hello`
Then the output should contain exactly "the
:
//url\n"
Scenario
:
Detached HEAD
Given
I am in detached HEAD
When
I run `hub pull-request`
...
...
@@ -1232,3 +1251,16 @@ Feature: hub pull-request
"""
And
the output should match /Given up after retrying for 5\.\d seconds\./
And
a file named
".git/PULLREQ_EDITMSG"
should exist
Scenario
:
Draft pull request
Given the GitHub API server
:
"""
post('/repos/mislav/coral/pulls') {
halt 400 unless request.env['HTTP_ACCEPT'] == 'application/vnd.github.shadow-cat-preview+json;charset=utf-8'
assert :draft => true
status 201
json :html_url => "the://url"
}
"""
When
I successfully run `hub pull-request -d -m wip`
Then the output should contain exactly "the
:
//url\n"
github/client.go
浏览文件 @
b99071f1
...
...
@@ -119,7 +119,7 @@ func (client *Client) CreatePullRequest(project *Project, params map[string]inte
return
}
res
,
err
:=
api
.
PostJSON
(
fmt
.
Sprintf
(
"repos/%s/%s/pulls"
,
project
.
Owner
,
project
.
Name
),
params
)
res
,
err
:=
api
.
PostJSON
Preview
(
fmt
.
Sprintf
(
"repos/%s/%s/pulls"
,
project
.
Owner
,
project
.
Name
),
params
,
draftsType
)
if
err
=
checkStatus
(
201
,
"creating pull request"
,
res
,
err
);
err
!=
nil
{
if
res
!=
nil
&&
res
.
StatusCode
==
404
{
projectUrl
:=
strings
.
SplitN
(
project
.
WebURL
(
""
,
""
,
""
),
"://"
,
2
)[
1
]
...
...
github/http.go
浏览文件 @
b99071f1
...
...
@@ -409,7 +409,6 @@ func (c *simpleClient) jsonRequest(method, path string, body interface{}, config
return
c
.
performRequest
(
method
,
path
,
buf
,
func
(
req
*
http
.
Request
)
{
req
.
Header
.
Set
(
"Content-Type"
,
"application/json; charset=utf-8"
)
req
.
Header
.
Set
(
"Accept"
,
"application/vnd.github.shadow-cat-preview"
)
if
configure
!=
nil
{
configure
(
req
)
}
...
...
@@ -434,6 +433,12 @@ func (c *simpleClient) PostJSON(path string, payload interface{}) (*simpleRespon
return
c
.
jsonRequest
(
"POST"
,
path
,
payload
,
nil
)
}
func
(
c
*
simpleClient
)
PostJSONPreview
(
path
string
,
payload
interface
{},
mimeType
string
)
(
*
simpleResponse
,
error
)
{
return
c
.
jsonRequest
(
"POST"
,
path
,
payload
,
func
(
req
*
http
.
Request
)
{
req
.
Header
.
Set
(
"Accept"
,
mimeType
)
})
}
func
(
c
*
simpleClient
)
PatchJSON
(
path
string
,
payload
interface
{})
(
*
simpleResponse
,
error
)
{
return
c
.
jsonRequest
(
"PATCH"
,
path
,
payload
,
nil
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录