Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
6325f0f5
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,发现更多精彩内容 >>
提交
6325f0f5
编写于
12月 22, 2011
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dirty (temporary) fix for clone command
references #98
上级
3b1a31f7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
3 deletion
+35
-3
lib/hub/commands.rb
lib/hub/commands.rb
+9
-3
test/hub_test.rb
test/hub_test.rb
+26
-0
未找到文件。
lib/hub/commands.rb
浏览文件 @
6325f0f5
...
@@ -180,8 +180,12 @@ module Hub
...
@@ -180,8 +180,12 @@ module Hub
# $ hub clone rtomayko/tilt
# $ hub clone rtomayko/tilt
# $ hub clone tilt
# $ hub clone tilt
if
arg
=~
NAME_WITH_OWNER_RE
if
arg
=~
NAME_WITH_OWNER_RE
project
=
github_project
(
arg
)
# FIXME: this logic shouldn't be duplicated here!
ssh
||=
args
[
0
]
!=
'submodule'
&&
project
.
owner
==
github_user
(
false
)
name
,
owner
=
arg
,
nil
owner
,
name
=
name
.
split
(
'/'
,
2
)
if
name
.
index
(
'/'
)
host
=
ENV
[
'GITHUB_HOST'
]
project
=
Context
::
GithubProject
.
new
(
nil
,
owner
||
github_user
(
true
,
host
),
name
,
host
||
'github.com'
)
ssh
||=
args
[
0
]
!=
'submodule'
&&
project
.
owner
==
github_user
(
false
,
host
)
||
host
args
[
idx
]
=
project
.
git_url
(
:private
=>
ssh
,
:https
=>
https_protocol?
)
args
[
idx
]
=
project
.
git_url
(
:private
=>
ssh
,
:https
=>
https_protocol?
)
end
end
break
break
...
@@ -383,7 +387,9 @@ module Hub
...
@@ -383,7 +387,9 @@ module Hub
def
init
(
args
)
def
init
(
args
)
if
args
.
delete
(
'-g'
)
if
args
.
delete
(
'-g'
)
# can't use default_host because there is no local_repo yet
# can't use default_host because there is no local_repo yet
project
=
Context
::
GithubProject
.
new
(
nil
,
github_user
,
File
.
basename
(
current_dir
),
'github.com'
)
# FIXME: this shouldn't be here!
host
=
ENV
[
'GITHUB_HOST'
]
project
=
Context
::
GithubProject
.
new
(
nil
,
github_user
(
true
,
host
),
File
.
basename
(
current_dir
),
host
||
'github.com'
)
url
=
project
.
git_url
(
:private
=>
true
,
:https
=>
https_protocol?
)
url
=
project
.
git_url
(
:private
=>
true
,
:https
=>
https_protocol?
)
args
.
after
[
'remote'
,
'add'
,
'origin'
,
url
]
args
.
after
[
'remote'
,
'add'
,
'origin'
,
url
]
end
end
...
...
test/hub_test.rb
浏览文件 @
6325f0f5
...
@@ -61,18 +61,21 @@ class HubTest < Test::Unit::TestCase
...
@@ -61,18 +61,21 @@ class HubTest < Test::Unit::TestCase
end
end
def
test_private_clone
def
test_private_clone
stub_no_git_repo
input
=
"clone -p rtomayko/ronn"
input
=
"clone -p rtomayko/ronn"
command
=
"git clone git@github.com:rtomayko/ronn.git"
command
=
"git clone git@github.com:rtomayko/ronn.git"
assert_command
input
,
command
assert_command
input
,
command
end
end
def
test_private_clone_noop
def
test_private_clone_noop
stub_no_git_repo
input
=
"--noop clone -p rtomayko/ronn"
input
=
"--noop clone -p rtomayko/ronn"
command
=
"git clone git@github.com:rtomayko/ronn.git
\n
"
command
=
"git clone git@github.com:rtomayko/ronn.git
\n
"
assert_output
command
,
hub
(
input
)
assert_output
command
,
hub
(
input
)
end
end
def
test_https_clone
def
test_https_clone
stub_no_git_repo
stub_https_is_preferred
stub_https_is_preferred
input
=
"clone rtomayko/ronn"
input
=
"clone rtomayko/ronn"
command
=
"git clone https://github.com/rtomayko/ronn.git"
command
=
"git clone https://github.com/rtomayko/ronn.git"
...
@@ -80,40 +83,47 @@ class HubTest < Test::Unit::TestCase
...
@@ -80,40 +83,47 @@ class HubTest < Test::Unit::TestCase
end
end
def
test_public_clone
def
test_public_clone
stub_no_git_repo
input
=
"clone rtomayko/ronn"
input
=
"clone rtomayko/ronn"
command
=
"git clone git://github.com/rtomayko/ronn.git"
command
=
"git clone git://github.com/rtomayko/ronn.git"
assert_command
input
,
command
assert_command
input
,
command
end
end
def
test_your_private_clone
def
test_your_private_clone
stub_no_git_repo
input
=
"clone -p resque"
input
=
"clone -p resque"
command
=
"git clone git@github.com:tpw/resque.git"
command
=
"git clone git@github.com:tpw/resque.git"
assert_command
input
,
command
assert_command
input
,
command
end
end
def
test_your_clone_is_always_private
def
test_your_clone_is_always_private
stub_no_git_repo
input
=
"clone resque"
input
=
"clone resque"
command
=
"git clone git@github.com:tpw/resque.git"
command
=
"git clone git@github.com:tpw/resque.git"
assert_command
input
,
command
assert_command
input
,
command
end
end
def
test_clone_repo_with_period
def
test_clone_repo_with_period
stub_no_git_repo
input
=
"clone hookio/hook.js"
input
=
"clone hookio/hook.js"
command
=
"git clone git://github.com/hookio/hook.js.git"
command
=
"git clone git://github.com/hookio/hook.js.git"
assert_command
input
,
command
assert_command
input
,
command
end
end
def
test_clone_with_arguments
def
test_clone_with_arguments
stub_no_git_repo
input
=
"clone --bare -o master resque"
input
=
"clone --bare -o master resque"
command
=
"git clone --bare -o master git@github.com:tpw/resque.git"
command
=
"git clone --bare -o master git@github.com:tpw/resque.git"
assert_command
input
,
command
assert_command
input
,
command
end
end
def
test_clone_with_arguments_and_destination
def
test_clone_with_arguments_and_destination
stub_no_git_repo
assert_forwarded
"clone --template=one/two git://github.com/tpw/resque.git --origin master resquetastic"
assert_forwarded
"clone --template=one/two git://github.com/tpw/resque.git --origin master resquetastic"
end
end
def
test_your_private_clone_fails_without_config
def
test_your_private_clone_fails_without_config
stub_no_git_repo
out
=
hub
(
"clone -p mustache"
)
do
out
=
hub
(
"clone -p mustache"
)
do
stub_github_user
(
nil
)
stub_github_user
(
nil
)
end
end
...
@@ -122,6 +132,7 @@ class HubTest < Test::Unit::TestCase
...
@@ -122,6 +132,7 @@ class HubTest < Test::Unit::TestCase
end
end
def
test_your_public_clone_fails_without_config
def
test_your_public_clone_fails_without_config
stub_no_git_repo
out
=
hub
(
"clone mustache"
)
do
out
=
hub
(
"clone mustache"
)
do
stub_github_user
(
nil
)
stub_github_user
(
nil
)
end
end
...
@@ -130,26 +141,32 @@ class HubTest < Test::Unit::TestCase
...
@@ -130,26 +141,32 @@ class HubTest < Test::Unit::TestCase
end
end
def
test_private_clone_left_alone
def
test_private_clone_left_alone
stub_no_git_repo
assert_forwarded
"clone git@github.com:rtomayko/ronn.git"
assert_forwarded
"clone git@github.com:rtomayko/ronn.git"
end
end
def
test_public_clone_left_alone
def
test_public_clone_left_alone
stub_no_git_repo
assert_forwarded
"clone git://github.com/rtomayko/ronn.git"
assert_forwarded
"clone git://github.com/rtomayko/ronn.git"
end
end
def
test_normal_public_clone_with_path
def
test_normal_public_clone_with_path
stub_no_git_repo
assert_forwarded
"clone git://github.com/rtomayko/ronn.git ronn-dev"
assert_forwarded
"clone git://github.com/rtomayko/ronn.git ronn-dev"
end
end
def
test_normal_clone_from_path
def
test_normal_clone_from_path
stub_no_git_repo
assert_forwarded
"clone ./test"
assert_forwarded
"clone ./test"
end
end
def
test_clone_with_host_alias
def
test_clone_with_host_alias
stub_no_git_repo
assert_forwarded
"clone server:git/repo.git"
assert_forwarded
"clone server:git/repo.git"
end
end
def
test_enterprise_clone
def
test_enterprise_clone
stub_no_git_repo
stub_github_user
(
'myfiname'
,
'git.my.org'
)
stub_github_user
(
'myfiname'
,
'git.my.org'
)
with_host_env
(
'git.my.org'
)
do
with_host_env
(
'git.my.org'
)
do
assert_command
"clone myrepo"
,
"git clone git@git.my.org:myfiname/myrepo.git"
assert_command
"clone myrepo"
,
"git clone git@git.my.org:myfiname/myrepo.git"
...
@@ -519,6 +536,15 @@ class HubTest < Test::Unit::TestCase
...
@@ -519,6 +536,15 @@ class HubTest < Test::Unit::TestCase
assert_commands
"git init"
,
"git remote add origin git@github.com:tpw/hub.git"
,
"init -g"
assert_commands
"git init"
,
"git remote add origin git@github.com:tpw/hub.git"
,
"init -g"
end
end
def
test_init_enterprise
stub_no_remotes
stub_no_git_repo
stub_github_user
(
'myfiname'
,
'git.my.org'
)
with_host_env
(
'git.my.org'
)
do
assert_commands
"git init"
,
"git remote add origin git@git.my.org:myfiname/hub.git"
,
"init -g"
end
end
def
test_init_no_login
def
test_init_no_login
out
=
hub
(
"init -g"
)
do
out
=
hub
(
"init -g"
)
do
stub_github_user
(
nil
)
stub_github_user
(
nil
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录