diff --git a/commands/args.go b/commands/args.go index 9c95c329..7f793665 100644 --- a/commands/args.go +++ b/commands/args.go @@ -53,17 +53,17 @@ func (a *Args) Replace(executable, command string, params ...string) { a.Command = command a.Params = params a.GlobalFlags = []string{} + a.noForward = false } func (a *Args) Commands() []*cmd.Cmd { - result := []*cmd.Cmd{} + result := a.beforeChain if !a.noForward { - result = append(result, a.beforeChain...) result = append(result, a.ToCmd()) - result = append(result, a.afterChain...) } + result = append(result, a.afterChain...) return result } diff --git a/commands/fork.go b/commands/fork.go index a1c5b9fe..29da7584 100644 --- a/commands/fork.go +++ b/commands/fork.go @@ -80,13 +80,12 @@ func fork(cmd *Command, args *Args) { } } - if flagForkNoRemote { - args.NoForward() - } else { + args.NoForward() + if !flagForkNoRemote { originURL := originRemote.URL.String() url := forkProject.GitURL("", "", true) - args.Replace("git", "remote", "add", "-f", newRemoteName, originURL) - args.After("git", "remote", "set-url", newRemoteName, url) + args.Before("git", "remote", "add", "-f", newRemoteName, originURL) + args.Before("git", "remote", "set-url", newRemoteName, url) args.AfterFn(func() error { ui.Printf("new remote: %s\n", newRemoteName)