@@ -34,7 +34,7 @@ func main() {
3434
3535 var ctx context.Context
3636 if defMgr , err := alias .GetDefaultAliasMgrWithNameAndInitialData (cmd .Name (), []alias.Alias {
37- {Name : "cl " , Command : "config list " },
37+ {Name : "cm " , Command : "checkout master " },
3838 }); err == nil {
3939 ctx = context .WithValue (context .Background (), alias .AliasKey , defMgr )
4040
@@ -51,22 +51,26 @@ func main() {
5151 var defMgr * alias.DefaultAliasManager
5252 var err error
5353 if defMgr , err = alias .GetDefaultAliasMgrWithNameAndInitialData (cmd .Name (), []alias.Alias {
54- {Name : "cl " , Command : "config list " },
54+ {Name : "cm " , Command : "checkout master " },
5555 }); err == nil {
5656 ctx = context .WithValue (context .Background (), alias .AliasKey , defMgr )
57+ var gitBinary string
58+ var targetCmd []string
59+ env := os .Environ ()
60+
61+ if gitBinary , err = exec .LookPath ("git" ); err != nil {
62+ panic ("cannot find git" )
63+ }
64+
5765 if ok , redirect := aliasCmd .RedirectToAlias (ctx , args ); ok {
58- env := os .Environ ()
59- var gitBinary string
60- if gitBinary , err = exec .LookPath ("git" ); err == nil {
61- syscall .Exec (gitBinary , append ([]string {"git" }, redirect ... ), env )
62- }
63- } else {
64- env := os .Environ ()
65- var gitBinary string
66- if gitBinary , err = exec .LookPath ("git" ); err == nil {
67- syscall .Exec (gitBinary , append ([]string {"git" }, args ... ), env )
68- }
66+ args = redirect
6967 }
68+
69+ preferGitHub (args )
70+ useMirror (args )
71+
72+ targetCmd = append ([]string {"git" }, args ... )
73+ _ = syscall .Exec (gitBinary , targetCmd , env ) // ignore the errors due to we've no power to deal with it
7074 } else {
7175 err = fmt .Errorf ("cannot get default alias manager, error: %v" , err )
7276 }
0 commit comments