提交 1eb87b82 编写于 作者: J Jingwen Owen Ou

Respect git alias

上级 b756e1dc
......@@ -106,6 +106,10 @@ func (a *Args) IsParamsEmpty() bool {
return a.ParamsSize() == 0
}
func (a *Args) PrependParams(params ...string) {
a.Params = append(params, a.Params...)
}
func (a *Args) AppendParams(params ...string) {
a.Params = append(a.Params, params...)
}
......
......@@ -5,6 +5,7 @@ import (
"fmt"
"github.com/jingweno/gh/cmd"
"github.com/jingweno/gh/git"
shellquote "github.com/kballard/go-shellquote"
)
type Runner struct {
......@@ -93,6 +94,10 @@ func expandAlias(args *Args) {
cmd := args.Command
expandedCmd, err := git.Config(fmt.Sprintf("alias.%s", cmd))
if err == nil && expandedCmd != "" {
args.Command = expandedCmd
words, err := shellquote.Split(expandedCmd)
if err != nil {
args.Command = words[0]
args.PrependParams(words[1:]...)
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册