Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
3d3facba
H
hub
项目概览
github
/
hub
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
3d3facba
编写于
2月 06, 2017
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/github/hub
上级
e0e53a16
7c892ca9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
102 addition
and
10 deletion
+102
-10
commands/checkout.go
commands/checkout.go
+17
-2
features/checkout.feature
features/checkout.feature
+60
-2
features/steps.rb
features/steps.rb
+8
-0
github/client.go
github/client.go
+7
-6
github/project.go
github/project.go
+10
-0
未找到文件。
commands/checkout.go
浏览文件 @
3d3facba
...
...
@@ -119,9 +119,24 @@ func transformCheckoutArgs(args *Args) error {
newBranchName
=
fmt
.
Sprintf
(
"%s-%s"
,
pullRequest
.
Head
.
Repo
.
Owner
.
Login
,
pullRequest
.
Head
.
Ref
)
}
}
refSpec
:=
fmt
.
Sprintf
(
"refs/pull/%s/head:%s"
,
id
,
newBranchName
)
newArgs
=
append
(
newArgs
,
newBranchName
)
args
.
Before
(
"git"
,
"fetch"
,
baseRemote
.
Name
,
refSpec
)
ref
:=
fmt
.
Sprintf
(
"refs/pull/%s/head"
,
id
)
args
.
Before
(
"git"
,
"fetch"
,
baseRemote
.
Name
,
fmt
.
Sprintf
(
"%s:%s"
,
ref
,
newBranchName
))
remote
:=
baseRemote
.
Name
mergeRef
:=
ref
if
pullRequest
.
MaintainerCanModify
&&
pullRequest
.
Head
.
Repo
!=
nil
{
project
,
err
:=
github
.
NewProjectFromRepo
(
pullRequest
.
Head
.
Repo
)
if
err
!=
nil
{
return
err
}
remote
=
project
.
GitURL
(
""
,
""
,
true
)
mergeRef
=
fmt
.
Sprintf
(
"refs/heads/%s"
,
pullRequest
.
Head
.
Ref
)
}
args
.
Before
(
"git"
,
"config"
,
fmt
.
Sprintf
(
"branch.%s.remote"
,
newBranchName
),
remote
)
args
.
Before
(
"git"
,
"config"
,
fmt
.
Sprintf
(
"branch.%s.merge"
,
newBranchName
),
mergeRef
)
}
replaceCheckoutParam
(
args
,
checkoutURL
,
newArgs
...
)
return
nil
...
...
features/checkout.feature
浏览文件 @
3d3facba
...
...
@@ -25,12 +25,13 @@ Feature: hub checkout <PULLREQ-URL>
:html_url => 'https://github.com/mojombo/jekyll',
:owner => { :login => "mojombo" },
}
}
}
, :maintainer_can_modify => false
}
"""
When I run `hub checkout -f https
:
//github.com/mojombo/jekyll/pull/7
7
-q`
Then "git fetch origin refs/pull/77/head
:
mislav-fixes"
should
be
run
And
"git checkout -f mislav-fixes -q"
should be run
And
"mislav-fixes"
should merge
"refs/pull/77/head"
from remote
"origin"
Scenario
:
No
matching remotes for pull request base
Given the GitHub API server
:
...
...
@@ -68,12 +69,13 @@ Feature: hub checkout <PULLREQ-URL>
:html_url => 'https://github.com/mojombo/jekyll',
:owner => { :login => "mojombo" },
}
}
}
, :maintainer_can_modify => false
}
"""
When I run `hub checkout https
:
//github.com/mojombo/jekyll/pull/7
7
fixes-from-mislav`
Then "git fetch origin refs/pull/77/head
:
fixes-from-mislav"
should
be
run
And
"git checkout fixes-from-mislav"
should be run
And
"fixes-from-mislav"
should merge
"refs/pull/77/head"
from remote
"origin"
Scenario
:
Same-repo
Given the GitHub API server
:
...
...
@@ -140,6 +142,7 @@ Feature: hub checkout <PULLREQ-URL>
When I run `hub checkout https
:
//github.com/mojombo/jekyll/pull/77`
Then "git fetch origin refs/pull/77/head
:
pr-77"
should
be
run
And
"git checkout pr-77"
should be run
And
"pr-77"
should merge
"refs/pull/77/head"
from remote
"origin"
Scenario
:
Reuse existing remote for head branch
Given the GitHub API server
:
...
...
@@ -192,3 +195,58 @@ Feature: hub checkout <PULLREQ-URL>
Then "git fetch mislav +refs/heads/fixes
:
refs/remotes/mislav/fixes"
should
be
run
And
"git checkout -f fixes -q"
should be run
And
"git merge --ff-only refs/remotes/mislav/fixes"
should be run
Scenario
:
Modifiable fork
Given the GitHub API server
:
"""
get('/repos/mojombo/jekyll/pulls/77') {
halt 406 unless request.env['HTTP_ACCEPT'] == 'application/vnd.github.v3+json;charset=utf-8'
json :head => {
:ref => "fixes",
:repo => {
:owner => { :login => "mislav" },
:name => "jekyll",
:html_url => "https://github.com/mislav/jekyll.git",
:private => false
},
}, :base => {
:repo => {
:name => 'jekyll',
:html_url => 'https://github.com/mojombo/jekyll',
:owner => { :login => "mojombo" },
}
}, :maintainer_can_modify => true
}
"""
When I run `hub checkout -f https
:
//github.com/mojombo/jekyll/pull/7
7
-q`
Then "git fetch origin refs/pull/77/head
:
mislav-fixes"
should
be
run
And
"git checkout -f mislav-fixes -q"
should be run
And "mislav-fixes" should merge "refs/heads/fixes" from remote "git@github.com
:
mislav/jekyll.git"
Scenario
:
Modifiable fork with HTTPS
Given the GitHub API server
:
"""
get('/repos/mojombo/jekyll/pulls/77') {
halt 406 unless request.env['HTTP_ACCEPT'] == 'application/vnd.github.v3+json;charset=utf-8'
json :head => {
:ref => "fixes",
:repo => {
:owner => { :login => "mislav" },
:name => "jekyll",
:html_url => "https://github.com/mislav/jekyll.git",
:private => false
},
}, :base => {
:repo => {
:name => 'jekyll',
:html_url => 'https://github.com/mojombo/jekyll',
:owner => { :login => "mojombo" },
}
}, :maintainer_can_modify => true
}
"""
And
HTTPS is preferred
When I run `hub checkout -f https
:
//github.com/mojombo/jekyll/pull/7
7
-q`
Then "git fetch origin refs/pull/77/head
:
mislav-fixes"
should
be
run
And
"git checkout -f mislav-fixes -q"
should be run
And "mislav-fixes" should merge "refs/heads/fixes" from remote "https
:
//github.com/mislav/jekyll.git"
features/steps.rb
浏览文件 @
3d3facba
...
...
@@ -208,6 +208,14 @@ Then(/^the "([^"]*)" submodule url should be "([^"]*)"$/) do |name, url|
expect
(
found
).
to
eql
(
url
)
end
Then
(
/^"([^"]*)" should merge "([^"]*)" from remote "([^"]*)"$/
)
do
|
name
,
merge
,
remote
|
actual_remote
=
run_silent
%(git config --get-all branch.#{name}.remote)
expect
(
remote
).
to
eql
(
actual_remote
)
actual_merge
=
run_silent
%(git config --get-all branch.#{name}.merge)
expect
(
merge
).
to
eql
(
actual_merge
)
end
Then
(
/^there should be no "([^"]*)" remote$/
)
do
|
remote_name
|
remotes
=
run_silent
(
'git remote'
).
split
(
"
\n
"
)
expect
(
remotes
).
to_not
include
(
remote_name
)
...
...
github/client.go
浏览文件 @
3d3facba
...
...
@@ -91,12 +91,13 @@ func (client *Client) PullRequestPatch(project *Project, id string) (patch io.Re
}
type
PullRequest
struct
{
ApiUrl
string
`json:"url"`
Number
int
`json:"number"`
HtmlUrl
string
`json:"html_url"`
Title
string
`json:"title"`
Head
*
PullRequestSpec
`json:"head"`
Base
*
PullRequestSpec
`json:"base"`
ApiUrl
string
`json:"url"`
Number
int
`json:"number"`
HtmlUrl
string
`json:"html_url"`
Title
string
`json:"title"`
MaintainerCanModify
bool
`json:"maintainer_can_modify"`
Head
*
PullRequestSpec
`json:"head"`
Base
*
PullRequestSpec
`json:"base"`
}
type
PullRequestSpec
struct
{
...
...
github/project.go
浏览文件 @
3d3facba
...
...
@@ -103,6 +103,16 @@ func preferredProtocol() string {
return
userProtocol
}
func
NewProjectFromRepo
(
repo
*
Repository
)
(
p
*
Project
,
err
error
)
{
url
,
err
:=
url
.
Parse
(
repo
.
HtmlUrl
)
if
err
!=
nil
{
return
}
p
,
err
=
NewProjectFromURL
(
url
)
return
}
func
NewProjectFromURL
(
url
*
url
.
URL
)
(
p
*
Project
,
err
error
)
{
if
!
knownGitHubHostsInclude
(
url
.
Host
)
{
err
=
&
GithubHostError
{
url
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录