Allow `args.Before/After` in combination with `NoForward`

This commit is contained in:
Mislav Marohnić 2016-09-11 03:58:41 +02:00
Родитель 3255fce35f
Коммит 8d5a3e9103
2 изменённых файлов: 7 добавлений и 8 удалений

Просмотреть файл

@ -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
}

Просмотреть файл

@ -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)