2020-01-07 21:42:33 +11:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2020-10-04 11:00:48 +11:00
|
|
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
2020-01-07 21:42:33 +11:00
|
|
|
)
|
|
|
|
|
2021-04-02 19:20:40 +11:00
|
|
|
func (gui *Gui) handleCreateGitFlowMenu() error {
|
2020-01-07 21:42:33 +11:00
|
|
|
branch := gui.getSelectedBranch()
|
|
|
|
if branch == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-01-08 14:10:01 +11:00
|
|
|
if !gui.Git.Flow.GitFlowEnabled() {
|
2020-03-28 11:47:54 +11:00
|
|
|
return gui.createErrorPanel("You need to install git-flow and enable it in this repo to use git-flow features")
|
2020-01-07 21:42:33 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
startHandler := func(branchType string) func() error {
|
|
|
|
return func() error {
|
2020-10-04 11:00:48 +11:00
|
|
|
title := utils.ResolvePlaceholderString(gui.Tr.NewGitFlowBranchPrompt, map[string]string{"branchType": branchType})
|
2020-11-28 13:35:58 +11:00
|
|
|
|
|
|
|
return gui.prompt(promptOpts{
|
|
|
|
title: title,
|
|
|
|
handleConfirm: func(name string) error {
|
2022-01-05 12:01:59 +11:00
|
|
|
gui.logAction(gui.Tr.Actions.GitFlowStart)
|
2021-04-10 11:40:42 +10:00
|
|
|
return gui.runSubprocessWithSuspenseAndRefresh(
|
2022-01-08 14:10:01 +11:00
|
|
|
gui.Git.Flow.StartCmdObj(branchType, name),
|
2021-04-02 21:30:39 +11:00
|
|
|
)
|
2020-11-28 13:35:58 +11:00
|
|
|
},
|
2020-01-07 21:42:33 +11:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-14 23:35:01 +11:00
|
|
|
menuItems := []*menuItem{
|
2020-01-07 21:42:33 +11:00
|
|
|
{
|
|
|
|
// not localising here because it's one to one with the actual git flow commands
|
2020-02-14 23:35:01 +11:00
|
|
|
displayString: fmt.Sprintf("finish branch '%s'", branch.Name),
|
|
|
|
onPress: func() error {
|
2022-01-07 19:56:33 +11:00
|
|
|
return gui.gitFlowFinishBranch(branch.Name)
|
2020-01-07 21:42:33 +11:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-02-14 23:35:01 +11:00
|
|
|
displayString: "start feature",
|
|
|
|
onPress: startHandler("feature"),
|
2020-01-07 21:42:33 +11:00
|
|
|
},
|
|
|
|
{
|
2020-02-14 23:35:01 +11:00
|
|
|
displayString: "start hotfix",
|
|
|
|
onPress: startHandler("hotfix"),
|
2020-01-07 21:42:33 +11:00
|
|
|
},
|
2020-04-20 18:20:10 +10:00
|
|
|
{
|
|
|
|
displayString: "start bugfix",
|
|
|
|
onPress: startHandler("bugfix"),
|
|
|
|
},
|
2020-01-07 21:42:33 +11:00
|
|
|
{
|
2020-02-14 23:35:01 +11:00
|
|
|
displayString: "start release",
|
|
|
|
onPress: startHandler("release"),
|
2020-01-07 21:42:33 +11:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-02-14 23:39:02 +11:00
|
|
|
return gui.createMenu("git flow", menuItems, createMenuOptions{})
|
2020-01-07 21:42:33 +11:00
|
|
|
}
|
2022-01-07 20:33:34 +11:00
|
|
|
|
|
|
|
func (gui *Gui) gitFlowFinishBranch(branchName string) error {
|
2022-01-08 14:10:01 +11:00
|
|
|
cmdObj, err := gui.Git.Flow.FinishCmdObj(branchName)
|
2022-01-07 20:33:34 +11:00
|
|
|
if err != nil {
|
|
|
|
return gui.surfaceError(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
gui.logAction(gui.Tr.Actions.GitFlowFinish)
|
|
|
|
return gui.runSubprocessWithSuspenseAndRefresh(cmdObj)
|
|
|
|
}
|