未验证 提交 844c9135 编写于 作者: M Mislav Marohnić 提交者: GitHub

Merge pull request #2168 from github/no-maintainer-edits

Add `hub pull-request --no-maintainer-edits` flag
......@@ -90,6 +90,11 @@ pull-request -i <ISSUE>
-d, --draft
Create the pull request as a draft.
--no-maintainer-edits
When creating a pull request from a fork, this disallows projects
maintainers from being able to push to the head branch of this fork.
Maintainer edits are allowed by default.
## Examples:
$ hub pull-request
[ opens a text editor for writing title and message ]
......@@ -319,8 +324,9 @@ of text is the title and the rest is the description.`, fullBase, fullHead))
pullRequestURL = "PULL_REQUEST_URL"
} else {
params := map[string]interface{}{
"base": base,
"head": fullHead,
"base": base,
"head": fullHead,
"maintainer_can_modify": !args.Flag.Bool("--no-maintainer-edits"),
}
if args.Flag.Bool("--draft") {
......
......@@ -7,13 +7,15 @@ Feature: hub pull-request
Scenario: Basic pull request
Given the GitHub API server:
"""
KNOWN_PARAMS = %w[title body base head draft issue maintainer_can_modify]
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?
halt 400 if (params.keys - KNOWN_PARAMS).any?
assert :title => 'hello',
:body => nil,
:base => 'master',
:head => 'mislav:master',
:maintainer_can_modify => true,
:draft => nil,
:issue => nil
status 201
......@@ -1277,3 +1279,15 @@ Feature: hub pull-request
"""
When I successfully run `hub pull-request -d -m wip`
Then the output should contain exactly "the://url\n"
Scenario: Disallow edits from maintainers
Given the GitHub API server:
"""
post('/repos/mislav/coral/pulls') {
assert :maintainer_can_modify => false
status 201
json :html_url => "the://url"
}
"""
When I successfully run `hub pull-request -m hello --no-maintainer-edits`
Then the output should contain exactly "the://url\n"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册