Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
8345753e
H
hub
项目概览
github
/
hub
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
8345753e
编写于
4月 29, 2010
作者:
C
Chris Wanstrath
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Code consistency tweaks
上级
98a5a280
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
19 addition
and
16 deletion
+19
-16
lib/hub/commands.rb
lib/hub/commands.rb
+7
-8
lib/hub/context.rb
lib/hub/context.rb
+12
-8
未找到文件。
lib/hub/commands.rb
浏览文件 @
8345753e
...
@@ -109,7 +109,7 @@ module Hub
...
@@ -109,7 +109,7 @@ module Hub
# $ hub remote add origin
# $ hub remote add origin
# > git remote add origin git://github.com/YOUR_LOGIN/THIS_REPO.git
# > git remote add origin git://github.com/YOUR_LOGIN/THIS_REPO.git
def
remote
(
args
)
def
remote
(
args
)
return
if
args
[
1
]
!=
'add'
or
args
.
last
=~
%r{.+?://|.+?@|^[./]}
return
if
args
[
1
]
!=
'add'
||
args
.
last
=~
%r{.+?://|.+?@|^[./]}
ssh
=
args
.
delete
(
'-p'
)
ssh
=
args
.
delete
(
'-p'
)
...
@@ -225,8 +225,7 @@ module Hub
...
@@ -225,8 +225,7 @@ module Hub
# $ hub browse
# $ hub browse
user
=
repo_user
user
=
repo_user
else
else
warn
"Usage: hub browse [<USER>/]<REPOSITORY>"
abort
"Usage: hub browse [<USER>/]<REPOSITORY>"
exit
(
1
)
end
end
params
=
{
:user
=>
user
,
:repo
=>
repo
}
params
=
{
:user
=>
user
,
:repo
=>
repo
}
...
@@ -240,7 +239,7 @@ module Hub
...
@@ -240,7 +239,7 @@ module Hub
params
[
:web
]
=
"/commits/
#{
branch
}
"
params
[
:web
]
=
"/commits/
#{
branch
}
"
when
'tree'
,
NilClass
when
'tree'
,
NilClass
branch
=
!
dest
&&
tracked_branch
branch
=
!
dest
&&
tracked_branch
params
[
:web
]
=
"/tree/
#{
branch
}
"
if
branch
and
branch
!=
'master'
params
[
:web
]
=
"/tree/
#{
branch
}
"
if
branch
&&
branch
!=
'master'
else
else
params
[
:web
]
=
"/
#{
subpage
}
"
params
[
:web
]
=
"/
#{
subpage
}
"
end
end
...
@@ -263,11 +262,11 @@ module Hub
...
@@ -263,11 +262,11 @@ module Hub
args
.
shift
args
.
shift
browse_command
(
args
)
do
browse_command
(
args
)
do
if
args
.
empty?
if
args
.
empty?
if
branch
=
tracked_branch
and
branch
!=
'master'
branch
=
tracked_branch
if
branch
&&
branch
!=
'master'
range
,
user
=
branch
,
repo_user
range
,
user
=
branch
,
repo_user
else
else
warn
"Usage: hub compare [USER] [<START>...]<END>"
abort
"Usage: hub compare [USER] [<START>...]<END>"
exit
(
1
)
end
end
else
else
range
=
args
.
pop
range
=
args
.
pop
...
...
lib/hub/context.rb
浏览文件 @
8345753e
...
@@ -12,7 +12,7 @@ module Hub
...
@@ -12,7 +12,7 @@ module Hub
REMOTES
=
Hash
.
new
do
|
cache
,
remote
|
REMOTES
=
Hash
.
new
do
|
cache
,
remote
|
url
=
GIT_CONFIG
[
"config remote.
#{
remote
}
.url"
]
url
=
GIT_CONFIG
[
"config remote.
#{
remote
}
.url"
]
if
url
and
url
.
to_s
=~
%r{
\b
github
\.
com[:/](.+)/(.+).git$}
if
url
&&
url
.
to_s
=~
%r{
\b
github
\.
com[:/](.+)/(.+).git$}
cache
[
remote
]
=
{
:user
=>
$1
,
:repo
=>
$2
}
cache
[
remote
]
=
{
:user
=>
$1
,
:repo
=>
$2
}
else
else
cache
[
remote
]
=
{
}
cache
[
remote
]
=
{
}
...
@@ -21,8 +21,6 @@ module Hub
...
@@ -21,8 +21,6 @@ module Hub
LGHCONF
=
"http://github.com/guides/local-github-config"
LGHCONF
=
"http://github.com/guides/local-github-config"
private
def
repo_owner
def
repo_owner
REMOTES
[
default_remote
][
:user
]
REMOTES
[
default_remote
][
:user
]
end
end
...
@@ -38,13 +36,19 @@ module Hub
...
@@ -38,13 +36,19 @@ module Hub
# Either returns the GitHub user as set by git-config(1) or aborts
# Either returns the GitHub user as set by git-config(1) or aborts
# with an error message.
# with an error message.
def
github_user
(
fatal
=
true
)
def
github_user
(
fatal
=
true
)
GIT_CONFIG
[
'config github.user'
]
or
if
user
=
GIT_CONFIG
[
'config github.user'
]
fatal
?
abort
(
"** No GitHub user set. See
#{
LGHCONF
}
"
)
:
nil
user
elsif
fatal
abort
(
"** No GitHub user set. See
#{
LGHCONF
}
"
)
end
end
end
def
github_token
(
fatal
=
true
)
def
github_token
(
fatal
=
true
)
GIT_CONFIG
[
'config github.token'
]
or
if
token
=
GIT_CONFIG
[
'config github.token'
]
fatal
?
abort
(
"** No GitHub token set. See
#{
LGHCONF
}
"
)
:
nil
token
elsif
fatal
abort
(
"** No GitHub token set. See
#{
LGHCONF
}
"
)
end
end
end
def
current_branch
def
current_branch
...
@@ -82,7 +86,7 @@ module Hub
...
@@ -82,7 +86,7 @@ module Hub
def
github_url
(
options
=
{})
def
github_url
(
options
=
{})
repo
=
options
[
:repo
]
repo
=
options
[
:repo
]
user
,
repo
=
repo
.
split
(
'/'
)
if
repo
and
repo
.
index
(
'/'
)
user
,
repo
=
repo
.
split
(
'/'
)
if
repo
&&
repo
.
index
(
'/'
)
user
||=
options
[
:user
]
||
github_user
user
||=
options
[
:user
]
||
github_user
repo
||=
repo_name
repo
||=
repo_name
secure
=
options
[
:private
]
secure
=
options
[
:private
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录