Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
8b1719f2
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,发现更多精彩内容 >>
提交
8b1719f2
编写于
1月 23, 2010
作者:
C
Chris Wanstrath
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of github.com:defunkt/hub
上级
c12de8a5
8d87891a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
132 addition
and
2 deletion
+132
-2
README.md
README.md
+28
-1
lib/hub/commands.rb
lib/hub/commands.rb
+50
-1
man/hub.1.ron
man/hub.1.ron
+19
-0
test/hub_test.rb
test/hub_test.rb
+35
-0
未找到文件。
README.md
浏览文件 @
8b1719f2
...
...
@@ -36,7 +36,8 @@ Install
`hub`
is most easily installed as a standalone script:
curl -s http://defunkt.github.com/hub/standalone > ~/bin/hub && chmod 755 !#:4
curl -s http://defunkt.github.com/hub/standalone > ~/bin/hub &&
chmod 755 ~/bin/hub
Assuming
`~/bin/`
is in your
`$PATH`
, you're ready to roll:
...
...
@@ -56,6 +57,17 @@ Though not recommended, `hub` can also be installed as a RubyGem:
(Yes, the gem name is
`git-hub`
.)
(It's not recommended because of the RubyGems startup time. See
[
this
gist
][
speed
]
for information.)
### Standalone via RubyGems
Yes, the gem name is still
`git-hub`
:
$ gem install git-hub
$ hub hub standalone > ~/bin/hub && chmod 755 ~/bin/hub
$ gem uninstall git-hub
### Source
You can also install from source:
...
...
@@ -129,6 +141,20 @@ superpowers:
> git push staging bert_timeout
> git push qa bert_timeout
### git browse
$ git browse schacon/ticgit
> open http://github.com/schacon/ticgit
$ git browse -p schacon/ticgit
> open http://github.com/schacon/ticgit
$ git browse resque
> open http://github.com/YOUR_USER/resque
$ git browse -p resque
> open https://github.com:YOUR_USER/resque
### git help
$ git help
...
...
@@ -216,3 +242,4 @@ Chris Wanstrath :: chris@ozmm.org :: @defunkt
[
0
]:
http://help.github.com/forking/
[
1
]:
http://github.com/defunkt/hub/issues
[
speed
]:
http://gist.github.com/284823
lib/hub/commands.rb
浏览文件 @
8b1719f2
...
...
@@ -52,6 +52,12 @@ module Hub
#
# $ hub clone -p kneath/hemingway
# > git clone git@github.com:kneath/hemingway.git
#
# $ hub clone tilt
# > git clone git://github.com/YOUR_LOGIN/tilt.
#
# $ hub clone -p github
# > git clone git@github.com:YOUR_LOGIN/hemingway.git
def
clone
(
args
)
ssh
=
args
.
delete
(
'-p'
)
...
...
@@ -63,13 +69,16 @@ module Hub
next
end
if
arg
=~
%r{.+?://|.+?@}
# Bail out early for URLs.
if
arg
=~
%r{.+?://|.+?@}
||
File
.
directory?
(
arg
)
# Bail out early for URLs and local paths.
break
elsif
arg
.
scan
(
'/'
).
size
==
1
&&
!
arg
.
include?
(
':'
)
# $ hub clone rtomayko/tilt
url
=
ssh
?
PRIVATE
:
PUBLIC
args
[
args
.
index
(
arg
)]
=
url
%
arg
.
split
(
'/'
)
break
elsif
arg
!~
/:|\//
# $ hub clone tilt
url
=
ssh
?
PRIVATE
:
PUBLIC
args
[
args
.
index
(
arg
)]
=
url
%
[
github_user
,
arg
]
break
...
...
@@ -126,6 +135,46 @@ module Hub
args
.
after
after
end
# $ hub browse pjhyett/github-services
# > open http://github.com/pjhyett/github-services
#
# $ hub browse -p pjhyett/github-fi
# > open https://github.com/pjhyett/github-fi
#
# $ hub browse github-services
# > open http://github.com/YOUR_LOGIN/github-services
#
# $ hub browse -p github-fi
# > open https://github.com/YOUR_LOGIN/github-fi
def
browse
(
args
)
protocol
=
args
.
delete
(
'-p'
)
?
'https'
:
'http'
if
args
.
last
.
include?
'/'
# $ hub browse pjhyett/github-services
user
,
repo
=
args
.
last
.
split
(
'/'
)
else
user
=
github_user
repo
=
args
.
last
end
browser
=
ENV
[
'BROWSER'
]
||
"open"
exec
"
#{
browser
}
#{
protocol
}
://github.com/
#{
user
}
/
#{
repo
}
"
end
# $ hub hub standalone
# Prints the "standalone" version of hub for an easy, memorable
# installation sequence:
#
# $ gem install git-hub
# $ hub standalone > ~/bin/standalone
# $ gem uninstall git-hub
def
hub
(
args
)
return
help
(
args
)
unless
args
[
1
]
==
'standalone'
require
'hub/standalone'
puts
Hub
::
Standalone
.
build
exit
end
def
alias
(
args
)
shells
=
{
'sh'
=>
'alias git=hub'
,
...
...
man/hub.1.ron
浏览文件 @
8b1719f2
...
...
@@ -44,6 +44,11 @@ After configuring the alias, the following commands have superpowers:
Push <REF> to each of <REMOTE-1> through <REMOTE-N> by executing
multiple `git push` commands.
* `git browse` [`-p`] [<USER>`/`]<REPOSITORY>:
Open repository's GitHub page in the system's default web browser
using `open(1)` or the `BROWSER` env variable. Use `-p` to open a
page with https.
* `git help`:
Display enhanced git-help(1).
...
...
@@ -102,6 +107,20 @@ cloning:
> git push staging bert_timeout
> git push qa bert_timeout
### git browse
$ git browse schacon/ticgit
> open http://github.com/schacon/ticgit
$ git browse -p schacon/ticgit
> open http://github.com/schacon/ticgit
$ git browse resque
> open http://github.com/YOUR_USER/resque
$ git browse -p resque
> open https://github.com:YOUR_USER/resque
### git help
$ git help
...
...
test/hub_test.rb
浏览文件 @
8b1719f2
...
...
@@ -70,6 +70,12 @@ class HubTest < Test::Unit::TestCase
assert_command
input
,
command
end
def
test_normal_clone_from_path
input
=
"clone ./test"
command
=
"git clone ./test"
assert_command
input
,
command
end
def
test_private_remote
input
=
"remote add -p rtomayko"
command
=
"git remote add rtomayko git@github.com:rtomayko/hub.git"
...
...
@@ -140,4 +146,33 @@ config
end
assert_equal
"** Can't find groff(1)
\n
"
,
help_manpage
end
def
test_hub_standalone
help_standalone
=
hub
(
"hub standalone"
)
assert_equal
Hub
::
Standalone
.
build
,
help_standalone
end
def
test_hub_open
input
=
"browse mojombo/bert"
command
=
"http://github.com/mojombo/bert
\n
"
assert_equal
command
,
hub
(
input
)
{
ENV
[
'BROWSER'
]
=
'echo'
}
end
def
test_hub_open_private
input
=
"browse -p bmizerany/sinatra"
command
=
"https://github.com/bmizerany/sinatra
\n
"
assert_equal
command
,
hub
(
input
)
{
ENV
[
'BROWSER'
]
=
'echo'
}
end
def
test_hub_open_self
input
=
"browse resque"
command
=
"http://github.com/tpw/resque
\n
"
assert_equal
command
,
hub
(
input
)
{
ENV
[
'BROWSER'
]
=
'echo'
}
end
def
test_hub_open_self_private
input
=
"browse -p github"
command
=
"https://github.com/tpw/github
\n
"
assert_equal
command
,
hub
(
input
)
{
ENV
[
'BROWSER'
]
=
'echo'
}
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录