Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
f08b9559
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,发现更多精彩内容 >>
提交
f08b9559
编写于
12月 08, 2009
作者:
C
Chris Wanstrath
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hub install standalone
上级
b0f705ed
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
0 deletion
+48
-0
lib/hub/commands.rb
lib/hub/commands.rb
+9
-0
lib/hub/standalone.rb
lib/hub/standalone.rb
+9
-0
test/standalone_test.rb
test/standalone_test.rb
+30
-0
未找到文件。
lib/hub/commands.rb
浏览文件 @
f08b9559
...
...
@@ -133,6 +133,15 @@ module Hub
end
alias_method
"--version"
,
:version
# $ hub install standalone ~/bin
def
install
(
args
)
command
,
subcommand
,
target
=
args
if
subcommand
.
to_s
==
'standalone'
Standalone
.
save
(
'hub'
,
target
.
empty?
?
'.'
:
target
)
exit
end
end
# $ hub help
# (print improved help text)
def
help
(
args
)
...
...
lib/hub/standalone.rb
浏览文件 @
f08b9559
...
...
@@ -18,6 +18,15 @@ premable
POSTAMBLE
=
"Hub::Runner.execute(*ARGV)"
def
save
(
filename
,
path
)
target
=
File
.
join
(
File
.
expand_path
(
path
),
filename
)
File
.
open
(
target
,
'w'
)
do
|
f
|
f
.
puts
build
end
rescue
Errno
::
EACCES
,
Errno
::
ENOENT
puts
"** can't write to
#{
target
}
"
end
def
build
root
=
File
.
dirname
(
__FILE__
)
...
...
test/standalone_test.rb
浏览文件 @
f08b9559
$LOAD_PATH
.
unshift
File
.
dirname
(
__FILE__
)
require
'helper'
require
'fileutils'
class
StandaloneTest
<
Test
::
Unit
::
TestCase
include
FileUtils
def
setup
rm
"hub"
if
File
.
exists?
'hub'
rm_rf
"/tmp/_hub_private"
if
File
.
exists?
'/tmp/_hub_private'
mkdir
"/tmp/_hub_private"
chmod
0400
,
"/tmp/_hub_private"
end
def
teardown
rm
"hub"
if
File
.
exists?
'hub'
rm_rf
"/tmp/_hub_private"
if
File
.
exists?
"/tmp/_hub_private"
end
def
test_standalone
standalone
=
Hub
::
Standalone
.
build
assert_includes
"This file, hub, is generated code"
,
standalone
...
...
@@ -11,4 +26,19 @@ class StandaloneTest < Test::Unit::TestCase
assert_includes
".execute(*ARGV)"
,
standalone
assert_not_includes
"module Standalone"
,
standalone
end
def
test_standalone_save
hub
(
"install standalone ."
)
assert_equal
Hub
::
Standalone
.
build
+
"
\n
"
,
File
.
read
(
'./hub'
)
end
def
test_standalone_save_permission_denied
out
=
hub
(
"install standalone /tmp/_hub_private"
)
assert_equal
"** can't write to /tmp/_hub_private/hub
\n
"
,
out
end
def
test_standalone_save_doesnt_exist
out
=
hub
(
"install standalone /tmp/something/not/real"
)
assert_equal
"** can't write to /tmp/something/not/real/hub
\n
"
,
out
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录