Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
2886114d
H
hub
项目概览
github
/
hub
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
2886114d
编写于
3月 20, 2012
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
better error message when `git create` fails
Fixes #147
上级
3c0d9fee
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
10 deletion
+23
-10
lib/hub/commands.rb
lib/hub/commands.rb
+1
-1
test/hub_test.rb
test/hub_test.rb
+22
-9
未找到文件。
lib/hub/commands.rb
浏览文件 @
2886114d
...
...
@@ -924,7 +924,7 @@ help
params
[
'homepage'
]
=
options
[
:homepage
]
if
options
[
:homepage
]
load_net_http
response
=
http_post
(
project
.
api_create_url
(
'
yaml
'
),
params
)
response
=
http_post
(
project
.
api_create_url
(
'
json
'
),
params
)
response
.
error!
unless
Net
::
HTTPSuccess
===
response
end
...
...
test/hub_test.rb
浏览文件 @
2886114d
...
...
@@ -589,7 +589,7 @@ class HubTest < Test::Unit::TestCase
def
test_create
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
yaml
/repos/create"
).
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
json
/repos/create"
).
with
(
:body
=>
{
'name'
=>
'hub'
})
expected
=
"remote add -f origin git@github.com:tpw/hub.git
\n
"
...
...
@@ -600,7 +600,7 @@ class HubTest < Test::Unit::TestCase
def
test_create_custom_name
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
,
'hubbub'
)
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
yaml
/repos/create"
).
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
json
/repos/create"
).
with
(
:body
=>
{
'name'
=>
'hubbub'
})
expected
=
"remote add -f origin git@github.com:tpw/hubbub.git
\n
"
...
...
@@ -611,7 +611,7 @@ class HubTest < Test::Unit::TestCase
def
test_create_in_organization
stub_no_remotes
stub_nonexisting_fork
(
'acme'
,
'hubbub'
)
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
yaml
/repos/create"
).
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
json
/repos/create"
).
with
(
:body
=>
{
'name'
=>
'acme/hubbub'
})
expected
=
"remote add -f origin git@github.com:acme/hubbub.git
\n
"
...
...
@@ -625,7 +625,7 @@ class HubTest < Test::Unit::TestCase
stub_request
(
:get
,
"http://
#{
auth
}
github.com/api/v2/yaml/repos/show/tpw/hub"
).
to_return
(
:status
=>
404
)
stub_request
(
:post
,
"http://
#{
auth
}
github.com/api/v2/
yaml
/repos/create"
).
stub_request
(
:post
,
"http://
#{
auth
}
github.com/api/v2/
json
/repos/create"
).
with
(
:body
=>
{
'name'
=>
'hub'
})
expected
=
"remote add -f origin git@github.com:tpw/hub.git
\n
"
...
...
@@ -641,7 +641,7 @@ class HubTest < Test::Unit::TestCase
def
test_create_failed
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
yaml
/repos/create"
).
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
json
/repos/create"
).
to_return
(
:status
=>
[
401
,
"Your token is fail"
])
expected
=
"Error creating repository: Your token is fail (HTTP 401)
\n
"
...
...
@@ -660,7 +660,7 @@ class HubTest < Test::Unit::TestCase
stub_request
(
:get
,
"https://
#{
auth
(
'mojombo'
,
'123abc'
)
}
github.com/api/v2/yaml/repos/show/mojombo/hub"
).
to_return
(
:status
=>
404
)
stub_request
(
:post
,
"https://
#{
auth
(
'mojombo'
,
'123abc'
)
}
github.com/api/v2/
yaml
/repos/create"
).
stub_request
(
:post
,
"https://
#{
auth
(
'mojombo'
,
'123abc'
)
}
github.com/api/v2/
json
/repos/create"
).
with
(
:body
=>
{
'name'
=>
'hub'
})
expected
=
"remote add -f origin git@github.com:mojombo/hub.git
\n
"
...
...
@@ -675,7 +675,7 @@ class HubTest < Test::Unit::TestCase
def
test_create_private_repository
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
yaml
/repos/create"
).
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
json
/repos/create"
).
with
(
:body
=>
{
'name'
=>
'hub'
,
'public'
=>
'0'
})
expected
=
"remote add -f origin git@github.com:tpw/hub.git
\n
"
...
...
@@ -683,10 +683,23 @@ class HubTest < Test::Unit::TestCase
assert_equal
expected
,
hub
(
"create -p"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_create_private_repository_fails
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/json/repos/create"
).
to_return
(
:status
=>
[
422
,
"Unprocessable Entity"
],
:headers
=>
{
"Content-type"
=>
"application/json"
},
:body
=>
%({"error":"repository creation failed: You are over your quota."})
)
expected
=
"Error creating repository: Unprocessable Entity (HTTP 422)
\n
"
expected
<<
"repository creation failed: You are over your quota.
\n
"
assert_equal
expected
,
hub
(
"create -p"
)
{
ENV
[
'GIT'
]
=
'echo'
}
end
def
test_create_with_description_and_homepage
stub_no_remotes
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
yaml
/repos/create"
).
with
(
:body
=>
{
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
json
/repos/create"
).
with
(
:body
=>
{
'name'
=>
'hub'
,
'description'
=>
'toyproject'
,
'homepage'
=>
'http://example.com'
})
...
...
@@ -736,7 +749,7 @@ class HubTest < Test::Unit::TestCase
def
test_create_origin_already_exists
stub_nonexisting_fork
(
'tpw'
)
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
yaml
/repos/create"
).
stub_request
(
:post
,
"https://
#{
auth
}
github.com/api/v2/
json
/repos/create"
).
with
(
:body
=>
{
'name'
=>
'hub'
})
expected
=
"remote -v
\n
created repository: tpw/hub
\n
"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录