Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
671759b2
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 搜索 >>
提交
671759b2
编写于
10月 03, 2016
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the case of unavailable fork in `checkout`
Fixes #1293
上级
4777bd36
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
2 deletion
+27
-2
commands/checkout.go
commands/checkout.go
+5
-1
features/checkout.feature
features/checkout.feature
+20
-0
github/client.go
github/client.go
+2
-1
未找到文件。
commands/checkout.go
浏览文件 @
671759b2
...
...
@@ -100,7 +100,11 @@ func transformCheckoutArgs(args *Args) error {
newArgs
=
append
(
newArgs
,
"-b"
,
newBranchName
,
"--track"
,
remoteBranch
)
}
else
{
if
newBranchName
==
""
{
newBranchName
=
fmt
.
Sprintf
(
"%s-%s"
,
pullRequest
.
Head
.
Repo
.
Owner
.
Login
,
pullRequest
.
Head
.
Ref
)
if
pullRequest
.
Head
.
Repo
==
nil
{
newBranchName
=
fmt
.
Sprintf
(
"pr-%s"
,
id
)
}
else
{
newBranchName
=
fmt
.
Sprintf
(
"%s-%s"
,
pullRequest
.
Head
.
Repo
.
Owner
.
Login
,
pullRequest
.
Head
.
Ref
)
}
}
refSpec
=
fmt
.
Sprintf
(
"pull/%s/head:%s"
,
id
,
newBranchName
)
newArgs
=
append
(
newArgs
,
newBranchName
)
...
...
features/checkout.feature
浏览文件 @
671759b2
...
...
@@ -120,3 +120,23 @@ Feature: hub checkout <PULLREQ-URL>
When I run `hub checkout https
:
//github.com/mojombo/jekyll/pull/7
7
mycustombranch`
Then "git fetch origin +refs/heads/fixes
:
refs/remotes/origin/fixes"
should
be
run
And
"git checkout -b mycustombranch --track origin/fixes"
should be run
Scenario
:
Unavailable fork
Given the GitHub API server
:
"""
get('/repos/mojombo/jekyll/pulls/77') {
json :head => {
:ref => "fixes",
:repo => nil
}, :base => {
:repo => {
:name => "jekyll",
:html_url => "https://github.com/mojombo/jekyll",
:owner => { :login => "mojombo" },
}
}
}
"""
When I run `hub checkout https
:
//github.com/mojombo/jekyll/pull/77`
Then "git fetch origin pull/77/head
:
pr-77"
should
be
run
And
"git checkout pr-77"
should be run
github/client.go
浏览文件 @
671759b2
...
...
@@ -107,7 +107,8 @@ type PullRequestSpec struct {
}
func
(
pr
*
PullRequest
)
IsSameRepo
()
bool
{
return
pr
.
Head
.
Repo
.
Name
==
pr
.
Base
.
Repo
.
Name
&&
return
pr
.
Head
.
Repo
!=
nil
&&
pr
.
Head
.
Repo
.
Name
==
pr
.
Base
.
Repo
.
Name
&&
pr
.
Head
.
Repo
.
Owner
.
Login
==
pr
.
Base
.
Repo
.
Owner
.
Login
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录