зеркало из https://github.com/mislav/hub.git
Respect git alias
This commit is contained in:
Родитель
b756e1dc5f
Коммит
1eb87b822b
|
@ -106,6 +106,10 @@ func (a *Args) IsParamsEmpty() bool {
|
||||||
return a.ParamsSize() == 0
|
return a.ParamsSize() == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Args) PrependParams(params ...string) {
|
||||||
|
a.Params = append(params, a.Params...)
|
||||||
|
}
|
||||||
|
|
||||||
func (a *Args) AppendParams(params ...string) {
|
func (a *Args) AppendParams(params ...string) {
|
||||||
a.Params = append(a.Params, params...)
|
a.Params = append(a.Params, params...)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/jingweno/gh/cmd"
|
"github.com/jingweno/gh/cmd"
|
||||||
"github.com/jingweno/gh/git"
|
"github.com/jingweno/gh/git"
|
||||||
|
shellquote "github.com/kballard/go-shellquote"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Runner struct {
|
type Runner struct {
|
||||||
|
@ -93,6 +94,10 @@ func expandAlias(args *Args) {
|
||||||
cmd := args.Command
|
cmd := args.Command
|
||||||
expandedCmd, err := git.Config(fmt.Sprintf("alias.%s", cmd))
|
expandedCmd, err := git.Config(fmt.Sprintf("alias.%s", cmd))
|
||||||
if err == nil && expandedCmd != "" {
|
if err == nil && expandedCmd != "" {
|
||||||
args.Command = expandedCmd
|
words, err := shellquote.Split(expandedCmd)
|
||||||
|
if err != nil {
|
||||||
|
args.Command = words[0]
|
||||||
|
args.PrependParams(words[1:]...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче