Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
3021e584
H
hub
项目概览
github
/
hub
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
3021e584
编写于
11月 07, 2016
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'akshatgoel-issue1305'
Closes #1332, fixes #1305
上级
490887a0
3792b5e7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
4 deletion
+48
-4
commands/runner.go
commands/runner.go
+14
-2
features/ci_status.feature
features/ci_status.feature
+8
-0
features/git_compatibility.feature
features/git_compatibility.feature
+7
-0
git/git.go
git/git.go
+19
-2
未找到文件。
commands/runner.go
浏览文件 @
3021e584
...
...
@@ -90,7 +90,9 @@ func (r *Runner) Execute() ExecError {
utils
.
Check
(
err
)
git
.
GlobalFlags
=
args
.
GlobalFlags
// preserve git global flags
expandAlias
(
args
)
if
!
isBuiltInHubCommand
(
args
.
Command
)
{
expandAlias
(
args
)
}
cmd
:=
r
.
Lookup
(
args
.
Command
)
if
cmd
!=
nil
&&
cmd
.
Runnable
()
{
...
...
@@ -163,7 +165,8 @@ func executeCommands(cmds []*cmd.Cmd, execFinal bool) error {
func
expandAlias
(
args
*
Args
)
{
cmd
:=
args
.
Command
expandedCmd
,
err
:=
git
.
Alias
(
cmd
)
if
err
==
nil
&&
expandedCmd
!=
""
{
if
err
==
nil
&&
expandedCmd
!=
""
&&
!
git
.
IsBuiltInGitCommand
(
cmd
)
{
words
,
e
:=
splitAliasCmd
(
expandedCmd
)
if
e
==
nil
{
args
.
Command
=
words
[
0
]
...
...
@@ -172,6 +175,15 @@ func expandAlias(args *Args) {
}
}
func
isBuiltInHubCommand
(
command
string
)
bool
{
for
hubCommand
,
_
:=
range
CmdRunner
.
All
()
{
if
hubCommand
==
command
{
return
true
}
}
return
false
}
func
splitAliasCmd
(
cmd
string
)
([]
string
,
error
)
{
if
cmd
==
""
{
return
nil
,
fmt
.
Errorf
(
"alias can't be empty"
)
...
...
features/ci_status.feature
浏览文件 @
3021e584
...
...
@@ -96,3 +96,11 @@ Feature: hub ci-status
Given
the remote commit state of
"git.my.org/michiels/pencilbox"
"the_sha"
is
"success"
When
I successfully run `hub ci-status the_sha`
Then
the output should contain exactly
"success\n"
Scenario
:
If alias named ci-status exists, it should not be expanded.
Given
there is a commit named
"the_sha"
Given
the remote commit state of
"michiels/pencilbox"
"the_sha"
is
"success"
When
I successfully run `git config --global alias.ci-status
"ci-status -v"
`
When
I run `hub ci-status the_sha`
Then
the output should contain exactly
"success\n"
And
the exit status should be 0
features/git_compatibility.feature
0 → 100644
浏览文件 @
3021e584
Feature
:
git-hub compatibility
Scenario
:
If alias named branch exists, it should not be expanded.
Given I am in "git
:
//github.com/rtomayko/ronn.git"
git
repo
And
the default branch for
"origin"
is
"master"
When
I successfully run `git config --global alias.branch
"branch -a"
`
When
I run `hub branch`
Then
the stdout should contain exactly
"* master\n"
git/git.go
浏览文件 @
3021e584
...
...
@@ -305,6 +305,7 @@ func LocalBranches() ([]string, error) {
if
err
==
nil
{
for
i
,
line
:=
range
lines
{
lines
[
i
]
=
strings
.
TrimPrefix
(
line
,
"* "
)
lines
[
i
]
=
strings
.
TrimPrefix
(
lines
[
i
],
" "
)
}
}
return
lines
,
err
...
...
@@ -315,8 +316,7 @@ func gitOutput(input ...string) (outputs []string, err error) {
out
,
err
:=
cmd
.
CombinedOutput
()
for
_
,
line
:=
range
strings
.
Split
(
out
,
"
\n
"
)
{
line
=
strings
.
TrimSpace
(
line
)
if
line
!=
""
{
if
strings
.
TrimSpace
(
line
)
!=
""
{
outputs
=
append
(
outputs
,
string
(
line
))
}
}
...
...
@@ -337,3 +337,20 @@ func gitCmd(args ...string) *cmd.Cmd {
return
cmd
}
func
IsBuiltInGitCommand
(
command
string
)
bool
{
helpCommandOutput
,
err
:=
gitOutput
(
"help"
,
"-a"
)
if
err
!=
nil
{
return
false
}
for
_
,
helpCommandOutputLine
:=
range
helpCommandOutput
{
if
strings
.
HasPrefix
(
helpCommandOutputLine
,
" "
)
{
for
_
,
gitCommand
:=
range
strings
.
Split
(
helpCommandOutputLine
,
" "
)
{
if
gitCommand
==
command
{
return
true
}
}
}
}
return
false
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录