Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
7dad4e4f
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 搜索 >>
未验证
提交
7dad4e4f
编写于
7月 07, 2018
作者:
M
Mislav Marohnić
提交者:
GitHub
7月 07, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1801 from github/custom-commands-docs-completions
Fix integration with git 2.18 shell completions
上级
c75cb1ca
f1771054
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
91 addition
and
11 deletion
+91
-11
commands/args.go
commands/args.go
+2
-1
commands/help.go
commands/help.go
+28
-3
commands/runner.go
commands/runner.go
+8
-2
etc/hub.bash_completion.sh
etc/hub.bash_completion.sh
+4
-0
etc/hub.fish_completion
etc/hub.fish_completion
+7
-0
etc/hub.zsh_completion
etc/hub.zsh_completion
+8
-0
features/git_compatibility.feature
features/git_compatibility.feature
+25
-0
features/help.feature
features/help.feature
+0
-4
features/support/fakebin/git
features/support/fakebin/git
+5
-0
share/man/man1/hub.1.ronn
share/man/man1/hub.1.ronn
+4
-1
未找到文件。
commands/args.go
浏览文件 @
7dad4e4f
...
...
@@ -208,6 +208,7 @@ func NewArgs(args []string) *Args {
const
(
noopFlag
=
"--noop"
versionFlag
=
"--version"
listCmds
=
"--list-cmds="
helpFlag
=
"--help"
configFlag
=
"-c"
chdirFlag
=
"-C"
...
...
@@ -226,7 +227,7 @@ func slurpGlobalFlags(args *[]string, globalFlags *[]string) {
if
slurpNextValue
{
commandIndex
=
i
+
1
slurpNextValue
=
false
}
else
if
arg
==
versionFlag
||
arg
==
helpFlag
||
!
looksLikeFlag
(
arg
)
{
}
else
if
arg
==
versionFlag
||
arg
==
helpFlag
||
strings
.
HasPrefix
(
arg
,
listCmds
)
||
!
looksLikeFlag
(
arg
)
{
break
}
else
{
commandIndex
=
i
+
1
...
...
commands/help.go
浏览文件 @
7dad4e4f
...
...
@@ -45,8 +45,15 @@ hub(1), git-help(1)
`
,
}
var
cmdListCmds
=
&
Command
{
Key
:
"--list-cmds"
,
Run
:
runListCmds
,
GitExtension
:
true
,
}
func
init
()
{
CmdRunner
.
Use
(
cmdHelp
,
"--help"
)
CmdRunner
.
Use
(
cmdListCmds
)
}
func
runHelp
(
helpCmd
*
Command
,
args
*
Args
)
{
...
...
@@ -89,6 +96,24 @@ func runHelp(helpCmd *Command, args *Args) {
}
}
func
runListCmds
(
cmd
*
Command
,
args
*
Args
)
{
listOthers
:=
false
parts
:=
strings
.
SplitN
(
args
.
Command
,
"="
,
2
)
for
_
,
kind
:=
range
strings
.
Split
(
parts
[
1
],
","
)
{
if
kind
==
"others"
{
listOthers
=
true
break
}
}
if
listOthers
{
args
.
AfterFn
(
func
()
error
{
ui
.
Println
(
strings
.
Join
(
customCommands
(),
"
\n
"
))
return
nil
})
}
}
func
displayManPage
(
manPage
string
,
args
*
Args
)
error
{
manProgram
,
_
:=
utils
.
CommandPath
(
"man"
)
if
manProgram
==
""
{
...
...
@@ -171,9 +196,9 @@ These GitHub commands are provided by hub:
create Create this repository on GitHub and add GitHub as origin
delete Delete a repository on GitHub
fork Make a fork of a remote repository on GitHub and add as remote
issue List or create issues
pr
Work with
pull requests
issue List or create
GitHub
issues
pr
List or checkout GitHub
pull requests
pull-request Open a pull request on GitHub
release List or create releases
release List or create
GitHub
releases
sync Fetch git objects from upstream and update branches
`
commands/runner.go
浏览文件 @
7dad4e4f
...
...
@@ -84,12 +84,18 @@ func (r *Runner) Execute() ExecError {
forceFail
=
true
}
cmdName
:=
args
.
Command
if
strings
.
Contains
(
cmdName
,
"="
)
{
cmdName
=
strings
.
SplitN
(
cmdName
,
"="
,
2
)[
0
]
}
git
.
GlobalFlags
=
args
.
GlobalFlags
// preserve git global flags
if
!
isBuiltInHubCommand
(
args
.
Command
)
{
if
!
isBuiltInHubCommand
(
cmdName
)
{
expandAlias
(
args
)
cmdName
=
args
.
Command
}
cmd
:=
r
.
Lookup
(
args
.
Command
)
cmd
:=
r
.
Lookup
(
cmdName
)
if
cmd
!=
nil
&&
cmd
.
Runnable
()
{
execErr
:=
r
.
Call
(
cmd
,
args
)
if
execErr
.
ExitCode
==
0
&&
forceFail
{
...
...
etc/hub.bash_completion.sh
浏览文件 @
7dad4e4f
...
...
@@ -17,8 +17,12 @@ if declare -F _git > /dev/null && ! declare -F __git_list_all_commands_without_h
cat
<<-
EOF
alias
pull-request
pr
issue
release
fork
create
delete
browse
compare
ci-status
...
...
etc/hub.fish_completion
浏览文件 @
7dad4e4f
...
...
@@ -21,8 +21,12 @@ complete -f -c hub -n '__fish_hub_needs_command' -a alias -d "show shell instruc
complete -f -c hub -n '__fish_hub_needs_command' -a browse -d "browse the project on GitHub"
complete -f -c hub -n '__fish_hub_needs_command' -a compare -d "lookup commit in GitHub Status API"
complete -f -c hub -n '__fish_hub_needs_command' -a create -d "create new repo on GitHub for the current project"
complete -f -c hub -n '__fish_hub_needs_command' -a delete -d "delete a GitHub repo"
complete -f -c hub -n '__fish_hub_needs_command' -a fork -d "fork origin repo on GitHub"
complete -f -c hub -n '__fish_hub_needs_command' -a pull-request -d "open a pull request on GitHub"
complete -f -c hub -n '__fish_hub_needs_command' -a pr -d "list or checkout a GitHub release"
complete -f -c hub -n '__fish_hub_needs_command' -a issue -d "list or create a GitHub issue"
complete -f -c hub -n '__fish_hub_needs_command' -a release -d "list or create a GitHub release"
complete -f -c hub -n '__fish_hub_needs_command' -a ci-status -d "display GitHub Status information for a commit"
complete -f -c hub -n '__fish_hub_needs_command' -a sync -d "update local branches from upstream"
...
...
@@ -58,5 +62,8 @@ complete -f -c hub -n ' __fish_hub_using_command create' -l browse -d "Open the
complete -f -c hub -n ' __fish_hub_using_command create' -s p -d "Create a private repository"
complete -f -c hub -n ' __fish_hub_using_command create' -s c -d "Put the URL of the new repository to clipboard instead of printing it."
complete -f -c hub -n ' __fish_hub_using_command create' -l copy -d "Put the URL of the new repository to clipboard instead of printing it."
# delete
complete -f -c hub -n ' __fish_hub_using_command delete' -s y -d "Skip the confirmation prompt"
complete -f -c hub -n ' __fish_hub_using_command delete' -l yes -d "Skip the confirmation prompt"
# ci-status
complete -f -c hub -n ' __fish_hub_using_command ci-status' -s v -d "Print detailed report of all status checks and their URLs"
etc/hub.zsh_completion
浏览文件 @
7dad4e4f
...
...
@@ -84,8 +84,12 @@ __hub_setup_zsh_fns () {
hub_commands=(
alias:'show shell instructions for wrapping git'
pull-request:'open a pull request on GitHub'
pr:'list or checkout a GitHub pull request'
issue:'list or create a GitHub issue'
release:'list or create a GitHub release'
fork:'fork origin repo on GitHub'
create:'create new repo on GitHub for the current project'
delete:'delete a GitHub repo'
browse:'browse the project on GitHub'
compare:'open GitHub compare view'
ci-status:'lookup commit in GitHub Status API'
...
...
@@ -111,8 +115,12 @@ __hub_setup_bash_fns () {
cat <<-EOF
alias
pull-request
pr
issue
release
fork
create
delete
browse
compare
ci-status
...
...
features/git_compatibility.feature
浏览文件 @
7dad4e4f
...
...
@@ -5,3 +5,28 @@ Feature: git-hub compatibility
When
I successfully run `git config --global alias.branch
"branch -a"
`
When
I run `hub branch`
Then
the stdout should contain exactly
"* master\n"
Scenario
:
List commands
When
I successfully run `hub --list-cmds=others`
Then the stdout should contain exactly
:
"""
add
branch
commit
alias
browse
ci-status
compare
create
delete
fork
issue
pr
pull-request
release
sync\n
"""
Scenario
:
Doesn't sabotage --exec-path
When
I successfully run `hub --exec-path`
Then
the output should not contain
"These GitHub commands"
features/help.feature
浏览文件 @
7dad4e4f
...
...
@@ -16,7 +16,3 @@ Feature: hub help
Scenario
:
Shows help for a subcommand
When
I successfully run `hub help hub-help`
Then the output should contain "Usage
:
hub
help"
Scenario
:
Doesn't sabotage --exec-path
When
I successfully run `hub --exec-path`
Then
the output should not contain
"These GitHub commands"
features/support/fakebin/git
浏览文件 @
7dad4e4f
...
...
@@ -7,6 +7,11 @@ command="$1"
[
"
$command
"
=
"config"
]
||
echo
git
"
$@
"
>>
"
$HOME
"
/.history
case
"
$command
"
in
"--list-cmds="
*
)
echo
add
echo
branch
echo
commit
;;
"clone"
|
"fetch"
|
"pull"
|
"push"
)
# don't actually execute these commands
exit
...
...
share/man/man1/hub.1.ronn
浏览文件 @
7dad4e4f
...
...
@@ -66,7 +66,7 @@ git but that are extended through hub, and custom ones that hub provides.
* hub-create(1):
Create a new repository on GitHub and add a git remote for it.
* hub-delete(1):
Delete a repository on Github.
...
...
@@ -76,6 +76,9 @@ git but that are extended through hub, and custom ones that hub provides.
* hub-pull-request(1):
Create a GitHub pull request.
* hub-pr(1):
List and checkout GitHub pull requests.
* hub-issue(1):
List and create GitHub issues.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录