mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-12 11:15:00 +02:00
1dd7307fde
more and more move rebase commit refreshing into existing abstraction and more and more WIP and more handling clicks properly fix merge conflicts update cheatsheet lots more preparation to start moving things into controllers WIP better typing expand on remotes controller moving more code into controllers
75 lines
1.8 KiB
Go
75 lines
1.8 KiB
Go
package gui
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/gui/popup"
|
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
|
)
|
|
|
|
func (gui *Gui) handleCreateGitFlowMenu() error {
|
|
branch := gui.getSelectedBranch()
|
|
if branch == nil {
|
|
return nil
|
|
}
|
|
|
|
if !gui.git.Flow.GitFlowEnabled() {
|
|
return gui.c.ErrorMsg("You need to install git-flow and enable it in this repo to use git-flow features")
|
|
}
|
|
|
|
startHandler := func(branchType string) func() error {
|
|
return func() error {
|
|
title := utils.ResolvePlaceholderString(gui.c.Tr.NewGitFlowBranchPrompt, map[string]string{"branchType": branchType})
|
|
|
|
return gui.c.Prompt(popup.PromptOpts{
|
|
Title: title,
|
|
HandleConfirm: func(name string) error {
|
|
gui.c.LogAction(gui.c.Tr.Actions.GitFlowStart)
|
|
return gui.runSubprocessWithSuspenseAndRefresh(
|
|
gui.git.Flow.StartCmdObj(branchType, name),
|
|
)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
|
|
return gui.c.Menu(popup.CreateMenuOptions{
|
|
Title: "git flow",
|
|
Items: []*popup.MenuItem{
|
|
{
|
|
// not localising here because it's one to one with the actual git flow commands
|
|
DisplayString: fmt.Sprintf("finish branch '%s'", branch.Name),
|
|
OnPress: func() error {
|
|
return gui.gitFlowFinishBranch(branch.Name)
|
|
},
|
|
},
|
|
{
|
|
DisplayString: "start feature",
|
|
OnPress: startHandler("feature"),
|
|
},
|
|
{
|
|
DisplayString: "start hotfix",
|
|
OnPress: startHandler("hotfix"),
|
|
},
|
|
{
|
|
DisplayString: "start bugfix",
|
|
OnPress: startHandler("bugfix"),
|
|
},
|
|
{
|
|
DisplayString: "start release",
|
|
OnPress: startHandler("release"),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func (gui *Gui) gitFlowFinishBranch(branchName string) error {
|
|
cmdObj, err := gui.git.Flow.FinishCmdObj(branchName)
|
|
if err != nil {
|
|
return gui.c.Error(err)
|
|
}
|
|
|
|
gui.c.LogAction(gui.c.Tr.Actions.GitFlowFinish)
|
|
return gui.runSubprocessWithSuspenseAndRefresh(cmdObj)
|
|
}
|