2022-01-16 05:46:53 +02:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/jesseduffield/gocui"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/commands/hosting_service"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
CheckoutRefFn func(refName string, opts types.CheckoutRefOptions) error
|
|
|
|
CreateGitResetMenuFn func(refName string) error
|
|
|
|
SwitchToCommitFilesContextFn func(SwitchToCommitFilesContextOpts) error
|
|
|
|
GetHostingServiceMgrFn func() *hosting_service.HostingServiceMgr
|
|
|
|
PullFilesFn func() error
|
|
|
|
CheckMergeOrRebase func(error) error
|
|
|
|
)
|
|
|
|
|
|
|
|
type LocalCommitsController struct {
|
2022-01-30 11:03:08 +02:00
|
|
|
c *types.ControllerCommon
|
2022-01-31 13:20:28 +02:00
|
|
|
context types.IListContext
|
2022-01-30 11:03:08 +02:00
|
|
|
os *oscommands.OSCommand
|
|
|
|
git *commands.GitCommand
|
|
|
|
tagsHelper *TagsHelper
|
|
|
|
refsHelper IRefsHelper
|
|
|
|
cherryPickHelper *CherryPickHelper
|
|
|
|
rebaseHelper *RebaseHelper
|
2022-01-16 05:46:53 +02:00
|
|
|
|
|
|
|
getSelectedLocalCommit func() *models.Commit
|
2022-01-31 13:20:28 +02:00
|
|
|
model *types.Model
|
2022-01-16 05:46:53 +02:00
|
|
|
getSelectedLocalCommitIdx func() int
|
2022-01-30 11:03:08 +02:00
|
|
|
CheckMergeOrRebase CheckMergeOrRebase
|
2022-01-16 05:46:53 +02:00
|
|
|
pullFiles PullFilesFn
|
|
|
|
getHostingServiceMgr GetHostingServiceMgrFn
|
|
|
|
switchToCommitFilesContext SwitchToCommitFilesContextFn
|
|
|
|
getLimitCommits func() bool
|
|
|
|
setLimitCommits func(bool)
|
|
|
|
getShowWholeGitGraph func() bool
|
|
|
|
setShowWholeGitGraph func(bool)
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ types.IController = &LocalCommitsController{}
|
|
|
|
|
|
|
|
func NewLocalCommitsController(
|
2022-01-29 10:09:20 +02:00
|
|
|
c *types.ControllerCommon,
|
2022-01-31 13:20:28 +02:00
|
|
|
context types.IListContext,
|
2022-01-16 05:46:53 +02:00
|
|
|
os *oscommands.OSCommand,
|
|
|
|
git *commands.GitCommand,
|
2022-01-30 01:23:39 +02:00
|
|
|
tagsHelper *TagsHelper,
|
|
|
|
refsHelper IRefsHelper,
|
2022-01-30 11:03:08 +02:00
|
|
|
cherryPickHelper *CherryPickHelper,
|
|
|
|
rebaseHelper *RebaseHelper,
|
2022-01-16 05:46:53 +02:00
|
|
|
getSelectedLocalCommit func() *models.Commit,
|
2022-01-31 13:20:28 +02:00
|
|
|
model *types.Model,
|
2022-01-16 05:46:53 +02:00
|
|
|
getSelectedLocalCommitIdx func() int,
|
2022-01-30 11:03:08 +02:00
|
|
|
CheckMergeOrRebase CheckMergeOrRebase,
|
2022-01-16 05:46:53 +02:00
|
|
|
pullFiles PullFilesFn,
|
|
|
|
getHostingServiceMgr GetHostingServiceMgrFn,
|
|
|
|
switchToCommitFilesContext SwitchToCommitFilesContextFn,
|
|
|
|
getLimitCommits func() bool,
|
|
|
|
setLimitCommits func(bool),
|
|
|
|
getShowWholeGitGraph func() bool,
|
|
|
|
setShowWholeGitGraph func(bool),
|
|
|
|
) *LocalCommitsController {
|
|
|
|
return &LocalCommitsController{
|
|
|
|
c: c,
|
2022-01-31 13:20:28 +02:00
|
|
|
context: context,
|
2022-01-16 05:46:53 +02:00
|
|
|
os: os,
|
|
|
|
git: git,
|
2022-01-30 01:23:39 +02:00
|
|
|
tagsHelper: tagsHelper,
|
|
|
|
refsHelper: refsHelper,
|
2022-01-30 11:03:08 +02:00
|
|
|
cherryPickHelper: cherryPickHelper,
|
|
|
|
rebaseHelper: rebaseHelper,
|
2022-01-16 05:46:53 +02:00
|
|
|
getSelectedLocalCommit: getSelectedLocalCommit,
|
2022-01-31 13:20:28 +02:00
|
|
|
model: model,
|
2022-01-16 05:46:53 +02:00
|
|
|
getSelectedLocalCommitIdx: getSelectedLocalCommitIdx,
|
2022-01-30 11:03:08 +02:00
|
|
|
CheckMergeOrRebase: CheckMergeOrRebase,
|
2022-01-16 05:46:53 +02:00
|
|
|
pullFiles: pullFiles,
|
|
|
|
getHostingServiceMgr: getHostingServiceMgr,
|
|
|
|
switchToCommitFilesContext: switchToCommitFilesContext,
|
|
|
|
getLimitCommits: getLimitCommits,
|
|
|
|
setLimitCommits: setLimitCommits,
|
|
|
|
getShowWholeGitGraph: getShowWholeGitGraph,
|
|
|
|
setShowWholeGitGraph: setShowWholeGitGraph,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-05 01:31:07 +02:00
|
|
|
func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding {
|
2022-01-16 05:46:53 +02:00
|
|
|
outsideFilterModeBindings := []*types.Binding{
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.SquashDown),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.squashDown,
|
|
|
|
Description: self.c.Tr.LcSquashDown,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.MarkCommitAsFixup),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.fixup,
|
|
|
|
Description: self.c.Tr.LcFixupCommit,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.RenameCommit),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.checkSelected(self.reword),
|
|
|
|
Description: self.c.Tr.LcRewordCommit,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.RenameCommitWithEditor),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.rewordEditor,
|
|
|
|
Description: self.c.Tr.LcRenameCommitEditor,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Universal.Remove),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.drop,
|
|
|
|
Description: self.c.Tr.LcDeleteCommit,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Universal.Edit),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.edit,
|
|
|
|
Description: self.c.Tr.LcEditCommit,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.PickCommit),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.pick,
|
|
|
|
Description: self.c.Tr.LcPickCommit,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.CreateFixupCommit),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.checkSelected(self.handleCreateFixupCommit),
|
|
|
|
Description: self.c.Tr.LcCreateFixupCommit,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.SquashAboveCommits),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.checkSelected(self.handleSquashAllAboveFixupCommits),
|
|
|
|
Description: self.c.Tr.LcSquashAboveCommits,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.MoveDownCommit),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.handleCommitMoveDown,
|
|
|
|
Description: self.c.Tr.LcMoveDownCommit,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.MoveUpCommit),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.handleCommitMoveUp,
|
|
|
|
Description: self.c.Tr.LcMoveUpCommit,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.AmendToCommit),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.handleCommitAmendTo,
|
|
|
|
Description: self.c.Tr.LcAmendToCommit,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.RevertCommit),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.checkSelected(self.handleCommitRevert),
|
|
|
|
Description: self.c.Tr.LcRevertCommit,
|
|
|
|
},
|
2022-01-30 11:03:08 +02:00
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Universal.New),
|
2022-01-30 11:03:08 +02:00
|
|
|
Modifier: gocui.ModNone,
|
|
|
|
Handler: self.checkSelected(self.newBranch),
|
|
|
|
Description: self.c.Tr.LcCreateNewBranchFromCommit,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.CherryPickCopy),
|
2022-01-30 11:03:08 +02:00
|
|
|
Handler: self.checkSelected(self.copy),
|
|
|
|
Description: self.c.Tr.LcCherryPickCopy,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.CherryPickCopyRange),
|
2022-01-30 11:03:08 +02:00
|
|
|
Handler: self.checkSelected(self.copyRange),
|
|
|
|
Description: self.c.Tr.LcCherryPickCopyRange,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.PasteCommits),
|
|
|
|
Handler: opts.Guards.OutsideFilterMode(self.paste),
|
2022-01-30 11:03:08 +02:00
|
|
|
Description: self.c.Tr.LcPasteCommits,
|
|
|
|
},
|
2022-01-16 05:46:53 +02:00
|
|
|
// overriding these navigation keybindings because we might need to load
|
|
|
|
// more commits on demand
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Universal.StartSearch),
|
2022-01-31 13:11:34 +02:00
|
|
|
Handler: self.openSearch,
|
2022-01-16 05:46:53 +02:00
|
|
|
Description: self.c.Tr.LcStartSearch,
|
|
|
|
Tag: "navigation",
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Universal.GotoBottom),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.gotoBottom,
|
|
|
|
Description: self.c.Tr.LcGotoBottom,
|
|
|
|
Tag: "navigation",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Key: gocui.MouseLeft,
|
2022-01-31 13:20:28 +02:00
|
|
|
Handler: func() error { return self.context.HandleClick(self.checkSelected(self.enter)) },
|
2022-01-16 05:46:53 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, binding := range outsideFilterModeBindings {
|
2022-02-05 01:31:07 +02:00
|
|
|
binding.Handler = opts.Guards.OutsideFilterMode(binding.Handler)
|
2022-01-16 05:46:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bindings := append(outsideFilterModeBindings, []*types.Binding{
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.OpenLogMenu),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.handleOpenLogMenu,
|
|
|
|
Description: self.c.Tr.LcOpenLogMenu,
|
|
|
|
OpensMenu: true,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.ViewResetOptions),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.checkSelected(self.handleCreateCommitResetMenu),
|
|
|
|
Description: self.c.Tr.LcResetToThisCommit,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Universal.GoInto),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.checkSelected(self.enter),
|
|
|
|
Description: self.c.Tr.LcViewCommitFiles,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.CheckoutCommit),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.checkSelected(self.handleCheckoutCommit),
|
|
|
|
Description: self.c.Tr.LcCheckoutCommit,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.TagCommit),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.checkSelected(self.handleTagCommit),
|
|
|
|
Description: self.c.Tr.LcTagCommit,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.CopyCommitMessageToClipboard),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.checkSelected(self.handleCopySelectedCommitMessageToClipboard),
|
|
|
|
Description: self.c.Tr.LcCopyCommitMessageToClipboard,
|
|
|
|
},
|
|
|
|
{
|
2022-02-05 01:31:07 +02:00
|
|
|
Key: opts.GetKey(opts.Config.Commits.OpenInBrowser),
|
2022-01-16 05:46:53 +02:00
|
|
|
Handler: self.checkSelected(self.handleOpenCommitInBrowser),
|
|
|
|
Description: self.c.Tr.LcOpenCommitInBrowser,
|
|
|
|
},
|
|
|
|
}...)
|
|
|
|
|
2022-02-05 01:31:07 +02:00
|
|
|
return bindings
|
2022-01-16 05:46:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) squashDown() error {
|
2022-01-31 13:20:28 +02:00
|
|
|
if len(self.model.Commits) <= 1 {
|
2022-01-16 05:46:53 +02:00
|
|
|
return self.c.ErrorMsg(self.c.Tr.YouNoCommitsToSquash)
|
|
|
|
}
|
|
|
|
|
|
|
|
applied, err := self.handleMidRebaseCommand("squash")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if applied {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-01-29 10:09:20 +02:00
|
|
|
return self.c.Ask(types.AskOpts{
|
2022-01-16 05:46:53 +02:00
|
|
|
Title: self.c.Tr.Squash,
|
|
|
|
Prompt: self.c.Tr.SureSquashThisCommit,
|
|
|
|
HandleConfirm: func() error {
|
|
|
|
return self.c.WithWaitingStatus(self.c.Tr.SquashingStatus, func() error {
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.SquashCommitDown)
|
|
|
|
return self.interactiveRebase("squash")
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) fixup() error {
|
2022-01-31 13:20:28 +02:00
|
|
|
if len(self.model.Commits) <= 1 {
|
2022-01-16 05:46:53 +02:00
|
|
|
return self.c.ErrorMsg(self.c.Tr.YouNoCommitsToSquash)
|
|
|
|
}
|
|
|
|
|
|
|
|
applied, err := self.handleMidRebaseCommand("fixup")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if applied {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-01-29 10:09:20 +02:00
|
|
|
return self.c.Ask(types.AskOpts{
|
2022-01-16 05:46:53 +02:00
|
|
|
Title: self.c.Tr.Fixup,
|
|
|
|
Prompt: self.c.Tr.SureFixupThisCommit,
|
|
|
|
HandleConfirm: func() error {
|
|
|
|
return self.c.WithWaitingStatus(self.c.Tr.FixingStatus, func() error {
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.FixupCommit)
|
|
|
|
return self.interactiveRebase("fixup")
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) reword(commit *models.Commit) error {
|
|
|
|
applied, err := self.handleMidRebaseCommand("reword")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if applied {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
message, err := self.git.Commit.GetCommitMessage(commit.Sha)
|
|
|
|
if err != nil {
|
|
|
|
return self.c.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: use the commit message panel here
|
2022-01-29 10:09:20 +02:00
|
|
|
return self.c.Prompt(types.PromptOpts{
|
2022-01-16 05:46:53 +02:00
|
|
|
Title: self.c.Tr.LcRewordCommit,
|
|
|
|
InitialContent: message,
|
|
|
|
HandleConfirm: func(response string) error {
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.RewordCommit)
|
2022-01-31 13:20:28 +02:00
|
|
|
if err := self.git.Rebase.RewordCommit(self.model.Commits, self.getSelectedLocalCommitIdx(), response); err != nil {
|
2022-01-16 05:46:53 +02:00
|
|
|
return self.c.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) rewordEditor() error {
|
|
|
|
applied, err := self.handleMidRebaseCommand("reword")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if applied {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.RewordCommit)
|
|
|
|
subProcess, err := self.git.Rebase.RewordCommitInEditor(
|
2022-01-31 13:20:28 +02:00
|
|
|
self.model.Commits, self.getSelectedLocalCommitIdx(),
|
2022-01-16 05:46:53 +02:00
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return self.c.Error(err)
|
|
|
|
}
|
|
|
|
if subProcess != nil {
|
|
|
|
return self.c.RunSubprocessAndRefresh(subProcess)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) drop() error {
|
|
|
|
applied, err := self.handleMidRebaseCommand("drop")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if applied {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-01-29 10:09:20 +02:00
|
|
|
return self.c.Ask(types.AskOpts{
|
2022-01-16 05:46:53 +02:00
|
|
|
Title: self.c.Tr.DeleteCommitTitle,
|
|
|
|
Prompt: self.c.Tr.DeleteCommitPrompt,
|
|
|
|
HandleConfirm: func() error {
|
|
|
|
return self.c.WithWaitingStatus(self.c.Tr.DeletingStatus, func() error {
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.DropCommit)
|
|
|
|
return self.interactiveRebase("drop")
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) edit() error {
|
|
|
|
applied, err := self.handleMidRebaseCommand("edit")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if applied {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func() error {
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.EditCommit)
|
|
|
|
return self.interactiveRebase("edit")
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) pick() error {
|
|
|
|
applied, err := self.handleMidRebaseCommand("pick")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if applied {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// at this point we aren't actually rebasing so we will interpret this as an
|
|
|
|
// attempt to pull. We might revoke this later after enabling configurable keybindings
|
|
|
|
return self.pullFiles()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) interactiveRebase(action string) error {
|
2022-01-31 13:20:28 +02:00
|
|
|
err := self.git.Rebase.InteractiveRebase(self.model.Commits, self.getSelectedLocalCommitIdx(), action)
|
2022-01-30 11:03:08 +02:00
|
|
|
return self.CheckMergeOrRebase(err)
|
2022-01-16 05:46:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// handleMidRebaseCommand sees if the selected commit is in fact a rebasing
|
|
|
|
// commit meaning you are trying to edit the todo file rather than actually
|
|
|
|
// begin a rebase. It then updates the todo file with that action
|
|
|
|
func (self *LocalCommitsController) handleMidRebaseCommand(action string) (bool, error) {
|
|
|
|
selectedCommit := self.getSelectedLocalCommit()
|
|
|
|
if selectedCommit.Status != "rebasing" {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// for now we do not support setting 'reword' because it requires an editor
|
|
|
|
// and that means we either unconditionally wait around for the subprocess to ask for
|
|
|
|
// our input or we set a lazygit client as the EDITOR env variable and have it
|
|
|
|
// request us to edit the commit message when prompted.
|
|
|
|
if action == "reword" {
|
|
|
|
return true, self.c.ErrorMsg(self.c.Tr.LcRewordNotSupported)
|
|
|
|
}
|
|
|
|
|
|
|
|
self.c.LogAction("Update rebase TODO")
|
|
|
|
self.c.LogCommand(
|
|
|
|
fmt.Sprintf("Updating rebase action of commit %s to '%s'", selectedCommit.ShortSha(), action),
|
|
|
|
false,
|
|
|
|
)
|
|
|
|
|
|
|
|
if err := self.git.Rebase.EditRebaseTodo(
|
|
|
|
self.getSelectedLocalCommitIdx(), action,
|
|
|
|
); err != nil {
|
|
|
|
return false, self.c.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return true, self.c.Refresh(types.RefreshOptions{
|
|
|
|
Mode: types.SYNC, Scope: []types.RefreshableView{types.REBASE_COMMITS},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) handleCommitMoveDown() error {
|
2022-01-31 13:20:28 +02:00
|
|
|
index := self.context.GetPanelState().GetSelectedLineIdx()
|
|
|
|
commits := self.model.Commits
|
|
|
|
selectedCommit := self.model.Commits[index]
|
2022-01-16 05:46:53 +02:00
|
|
|
if selectedCommit.Status == "rebasing" {
|
|
|
|
if commits[index+1].Status != "rebasing" {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// logging directly here because MoveTodoDown doesn't have enough information
|
|
|
|
// to provide a useful log
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.MoveCommitDown)
|
|
|
|
self.c.LogCommand(fmt.Sprintf("Moving commit %s down", selectedCommit.ShortSha()), false)
|
|
|
|
|
|
|
|
if err := self.git.Rebase.MoveTodoDown(index); err != nil {
|
|
|
|
return self.c.Error(err)
|
|
|
|
}
|
2022-01-30 07:38:07 +02:00
|
|
|
// TODO: use MoveSelectedLine
|
2022-01-31 13:20:28 +02:00
|
|
|
_ = self.context.HandleNextLine()
|
2022-01-16 05:46:53 +02:00
|
|
|
return self.c.Refresh(types.RefreshOptions{
|
|
|
|
Mode: types.SYNC, Scope: []types.RefreshableView{types.REBASE_COMMITS},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return self.c.WithWaitingStatus(self.c.Tr.MovingStatus, func() error {
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.MoveCommitDown)
|
2022-01-31 13:20:28 +02:00
|
|
|
err := self.git.Rebase.MoveCommitDown(self.model.Commits, index)
|
2022-01-16 05:46:53 +02:00
|
|
|
if err == nil {
|
2022-01-30 07:38:07 +02:00
|
|
|
// TODO: use MoveSelectedLine
|
2022-01-31 13:20:28 +02:00
|
|
|
_ = self.context.HandleNextLine()
|
2022-01-16 05:46:53 +02:00
|
|
|
}
|
2022-01-30 11:03:08 +02:00
|
|
|
return self.CheckMergeOrRebase(err)
|
2022-01-16 05:46:53 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) handleCommitMoveUp() error {
|
2022-01-31 13:20:28 +02:00
|
|
|
index := self.context.GetPanelState().GetSelectedLineIdx()
|
2022-01-16 05:46:53 +02:00
|
|
|
if index == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-01-31 13:20:28 +02:00
|
|
|
selectedCommit := self.model.Commits[index]
|
2022-01-16 05:46:53 +02:00
|
|
|
if selectedCommit.Status == "rebasing" {
|
|
|
|
// logging directly here because MoveTodoDown doesn't have enough information
|
|
|
|
// to provide a useful log
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.MoveCommitUp)
|
|
|
|
self.c.LogCommand(
|
|
|
|
fmt.Sprintf("Moving commit %s up", selectedCommit.ShortSha()),
|
|
|
|
false,
|
|
|
|
)
|
|
|
|
|
|
|
|
if err := self.git.Rebase.MoveTodoDown(index - 1); err != nil {
|
|
|
|
return self.c.Error(err)
|
|
|
|
}
|
2022-01-31 13:20:28 +02:00
|
|
|
_ = self.context.HandlePrevLine()
|
2022-01-16 05:46:53 +02:00
|
|
|
return self.c.Refresh(types.RefreshOptions{
|
|
|
|
Mode: types.SYNC, Scope: []types.RefreshableView{types.REBASE_COMMITS},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return self.c.WithWaitingStatus(self.c.Tr.MovingStatus, func() error {
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.MoveCommitUp)
|
2022-01-31 13:20:28 +02:00
|
|
|
err := self.git.Rebase.MoveCommitDown(self.model.Commits, index-1)
|
2022-01-16 05:46:53 +02:00
|
|
|
if err == nil {
|
2022-01-31 13:20:28 +02:00
|
|
|
_ = self.context.HandlePrevLine()
|
2022-01-16 05:46:53 +02:00
|
|
|
}
|
2022-01-30 11:03:08 +02:00
|
|
|
return self.CheckMergeOrRebase(err)
|
2022-01-16 05:46:53 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) handleCommitAmendTo() error {
|
2022-01-29 10:09:20 +02:00
|
|
|
return self.c.Ask(types.AskOpts{
|
2022-01-16 05:46:53 +02:00
|
|
|
Title: self.c.Tr.AmendCommitTitle,
|
|
|
|
Prompt: self.c.Tr.AmendCommitPrompt,
|
|
|
|
HandleConfirm: func() error {
|
|
|
|
return self.c.WithWaitingStatus(self.c.Tr.AmendingStatus, func() error {
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.AmendCommit)
|
|
|
|
err := self.git.Rebase.AmendTo(self.getSelectedLocalCommit().Sha)
|
2022-01-30 11:03:08 +02:00
|
|
|
return self.CheckMergeOrRebase(err)
|
2022-01-16 05:46:53 +02:00
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) handleCommitRevert(commit *models.Commit) error {
|
|
|
|
if commit.IsMerge() {
|
|
|
|
return self.createRevertMergeCommitMenu(commit)
|
|
|
|
} else {
|
2022-01-29 10:09:20 +02:00
|
|
|
return self.c.Ask(types.AskOpts{
|
2022-01-16 05:46:53 +02:00
|
|
|
Title: self.c.Tr.Actions.RevertCommit,
|
|
|
|
Prompt: utils.ResolvePlaceholderString(
|
|
|
|
self.c.Tr.ConfirmRevertCommit,
|
|
|
|
map[string]string{
|
|
|
|
"selectedCommit": commit.ShortSha(),
|
|
|
|
}),
|
|
|
|
HandleConfirm: func() error {
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.RevertCommit)
|
|
|
|
if err := self.git.Commit.Revert(commit.Sha); err != nil {
|
|
|
|
return self.c.Error(err)
|
|
|
|
}
|
|
|
|
return self.afterRevertCommit()
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) createRevertMergeCommitMenu(commit *models.Commit) error {
|
2022-01-29 10:09:20 +02:00
|
|
|
menuItems := make([]*types.MenuItem, len(commit.Parents))
|
2022-01-16 05:46:53 +02:00
|
|
|
for i, parentSha := range commit.Parents {
|
|
|
|
i := i
|
|
|
|
message, err := self.git.Commit.GetCommitMessageFirstLine(parentSha)
|
|
|
|
if err != nil {
|
|
|
|
return self.c.Error(err)
|
|
|
|
}
|
|
|
|
|
2022-01-29 10:09:20 +02:00
|
|
|
menuItems[i] = &types.MenuItem{
|
2022-01-16 05:46:53 +02:00
|
|
|
DisplayString: fmt.Sprintf("%s: %s", utils.SafeTruncate(parentSha, 8), message),
|
|
|
|
OnPress: func() error {
|
|
|
|
parentNumber := i + 1
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.RevertCommit)
|
|
|
|
if err := self.git.Commit.RevertMerge(commit.Sha, parentNumber); err != nil {
|
|
|
|
return self.c.Error(err)
|
|
|
|
}
|
|
|
|
return self.afterRevertCommit()
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-29 10:09:20 +02:00
|
|
|
return self.c.Menu(types.CreateMenuOptions{Title: self.c.Tr.SelectParentCommitForMerge, Items: menuItems})
|
2022-01-16 05:46:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) afterRevertCommit() error {
|
2022-01-31 13:20:28 +02:00
|
|
|
_ = self.context.HandleNextLine()
|
2022-01-16 05:46:53 +02:00
|
|
|
return self.c.Refresh(types.RefreshOptions{
|
|
|
|
Mode: types.BLOCK_UI, Scope: []types.RefreshableView{types.COMMITS, types.BRANCHES},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) enter(commit *models.Commit) error {
|
|
|
|
return self.switchToCommitFilesContext(SwitchToCommitFilesContextOpts{
|
|
|
|
RefName: commit.Sha,
|
|
|
|
CanRebase: true,
|
2022-01-31 13:20:28 +02:00
|
|
|
Context: self.context,
|
2022-01-16 05:46:53 +02:00
|
|
|
WindowName: "commits",
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) handleCreateFixupCommit(commit *models.Commit) error {
|
|
|
|
prompt := utils.ResolvePlaceholderString(
|
|
|
|
self.c.Tr.SureCreateFixupCommit,
|
|
|
|
map[string]string{
|
|
|
|
"commit": commit.Sha,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2022-01-29 10:09:20 +02:00
|
|
|
return self.c.Ask(types.AskOpts{
|
2022-01-16 05:46:53 +02:00
|
|
|
Title: self.c.Tr.CreateFixupCommit,
|
|
|
|
Prompt: prompt,
|
|
|
|
HandleConfirm: func() error {
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.CreateFixupCommit)
|
|
|
|
if err := self.git.Commit.CreateFixupCommit(commit.Sha); err != nil {
|
|
|
|
return self.c.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) handleSquashAllAboveFixupCommits(commit *models.Commit) error {
|
|
|
|
prompt := utils.ResolvePlaceholderString(
|
|
|
|
self.c.Tr.SureSquashAboveCommits,
|
|
|
|
map[string]string{
|
|
|
|
"commit": commit.Sha,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2022-01-29 10:09:20 +02:00
|
|
|
return self.c.Ask(types.AskOpts{
|
2022-01-16 05:46:53 +02:00
|
|
|
Title: self.c.Tr.SquashAboveCommits,
|
|
|
|
Prompt: prompt,
|
|
|
|
HandleConfirm: func() error {
|
|
|
|
return self.c.WithWaitingStatus(self.c.Tr.SquashingStatus, func() error {
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.SquashAllAboveFixupCommits)
|
|
|
|
err := self.git.Rebase.SquashAllAboveFixupCommits(commit.Sha)
|
2022-01-30 11:03:08 +02:00
|
|
|
return self.CheckMergeOrRebase(err)
|
2022-01-16 05:46:53 +02:00
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) handleTagCommit(commit *models.Commit) error {
|
2022-01-30 01:23:39 +02:00
|
|
|
return self.tagsHelper.CreateTagMenu(commit.Sha, func() {})
|
2022-01-16 05:46:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) handleCheckoutCommit(commit *models.Commit) error {
|
2022-01-29 10:09:20 +02:00
|
|
|
return self.c.Ask(types.AskOpts{
|
2022-01-16 05:46:53 +02:00
|
|
|
Title: self.c.Tr.LcCheckoutCommit,
|
|
|
|
Prompt: self.c.Tr.SureCheckoutThisCommit,
|
|
|
|
HandleConfirm: func() error {
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.CheckoutCommit)
|
2022-01-30 01:23:39 +02:00
|
|
|
return self.refsHelper.CheckoutRef(commit.Sha, types.CheckoutRefOptions{})
|
2022-01-16 05:46:53 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) handleCreateCommitResetMenu(commit *models.Commit) error {
|
2022-01-30 01:23:39 +02:00
|
|
|
return self.refsHelper.CreateGitResetMenu(commit.Sha)
|
2022-01-16 05:46:53 +02:00
|
|
|
}
|
|
|
|
|
2022-01-31 13:11:34 +02:00
|
|
|
func (self *LocalCommitsController) openSearch() error {
|
2022-01-16 05:46:53 +02:00
|
|
|
// we usually lazyload these commits but now that we're searching we need to load them now
|
|
|
|
if self.getLimitCommits() {
|
|
|
|
self.setLimitCommits(false)
|
|
|
|
if err := self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.COMMITS}}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-31 13:11:34 +02:00
|
|
|
self.c.OpenSearch()
|
|
|
|
|
|
|
|
return nil
|
2022-01-16 05:46:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) gotoBottom() error {
|
|
|
|
// we usually lazyload these commits but now that we're jumping to the bottom we need to load them now
|
|
|
|
if self.getLimitCommits() {
|
|
|
|
self.setLimitCommits(false)
|
|
|
|
if err := self.c.Refresh(types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.COMMITS}}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-31 13:20:28 +02:00
|
|
|
_ = self.context.HandleGotoBottom()
|
2022-01-16 05:46:53 +02:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) handleCopySelectedCommitMessageToClipboard(commit *models.Commit) error {
|
|
|
|
message, err := self.git.Commit.GetCommitMessage(commit.Sha)
|
|
|
|
if err != nil {
|
|
|
|
return self.c.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.CopyCommitMessageToClipboard)
|
|
|
|
if err := self.os.CopyToClipboard(message); err != nil {
|
|
|
|
return self.c.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
self.c.Toast(self.c.Tr.CommitMessageCopiedToClipboard)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) handleOpenLogMenu() error {
|
2022-01-29 10:09:20 +02:00
|
|
|
return self.c.Menu(types.CreateMenuOptions{
|
2022-01-16 05:46:53 +02:00
|
|
|
Title: self.c.Tr.LogMenuTitle,
|
2022-01-29 10:09:20 +02:00
|
|
|
Items: []*types.MenuItem{
|
2022-01-16 05:46:53 +02:00
|
|
|
{
|
|
|
|
DisplayString: self.c.Tr.ToggleShowGitGraphAll,
|
|
|
|
OnPress: func() error {
|
|
|
|
self.setShowWholeGitGraph(!self.getShowWholeGitGraph())
|
|
|
|
|
|
|
|
if self.getShowWholeGitGraph() {
|
|
|
|
self.setLimitCommits(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
return self.c.WithWaitingStatus(self.c.Tr.LcLoadingCommits, func() error {
|
|
|
|
return self.c.Refresh(types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.COMMITS}})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DisplayString: self.c.Tr.ShowGitGraph,
|
|
|
|
OpensMenu: true,
|
|
|
|
OnPress: func() error {
|
|
|
|
onPress := func(value string) func() error {
|
|
|
|
return func() error {
|
|
|
|
self.c.UserConfig.Git.Log.ShowGraph = value
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
2022-01-29 10:09:20 +02:00
|
|
|
return self.c.Menu(types.CreateMenuOptions{
|
2022-01-16 05:46:53 +02:00
|
|
|
Title: self.c.Tr.LogMenuTitle,
|
2022-01-29 10:09:20 +02:00
|
|
|
Items: []*types.MenuItem{
|
2022-01-16 05:46:53 +02:00
|
|
|
{
|
|
|
|
DisplayString: "always",
|
|
|
|
OnPress: onPress("always"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DisplayString: "never",
|
|
|
|
OnPress: onPress("never"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DisplayString: "when maximised",
|
|
|
|
OnPress: onPress("when-maximised"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DisplayString: self.c.Tr.SortCommits,
|
|
|
|
OpensMenu: true,
|
|
|
|
OnPress: func() error {
|
|
|
|
onPress := func(value string) func() error {
|
|
|
|
return func() error {
|
|
|
|
self.c.UserConfig.Git.Log.Order = value
|
|
|
|
return self.c.WithWaitingStatus(self.c.Tr.LcLoadingCommits, func() error {
|
|
|
|
return self.c.Refresh(types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.COMMITS}})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-29 10:09:20 +02:00
|
|
|
return self.c.Menu(types.CreateMenuOptions{
|
2022-01-16 05:46:53 +02:00
|
|
|
Title: self.c.Tr.LogMenuTitle,
|
2022-01-29 10:09:20 +02:00
|
|
|
Items: []*types.MenuItem{
|
2022-01-16 05:46:53 +02:00
|
|
|
{
|
|
|
|
DisplayString: "topological (topo-order)",
|
|
|
|
OnPress: onPress("topo-order"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DisplayString: "date-order",
|
|
|
|
OnPress: onPress("date-order"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
DisplayString: "author-date-order",
|
|
|
|
OnPress: onPress("author-date-order"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) handleOpenCommitInBrowser(commit *models.Commit) error {
|
|
|
|
hostingServiceMgr := self.getHostingServiceMgr()
|
|
|
|
|
|
|
|
url, err := hostingServiceMgr.GetCommitURL(commit.Sha)
|
|
|
|
if err != nil {
|
|
|
|
return self.c.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
self.c.LogAction(self.c.Tr.Actions.OpenCommitInBrowser)
|
|
|
|
if err := self.os.OpenLink(url); err != nil {
|
|
|
|
return self.c.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) checkSelected(callback func(*models.Commit) error) func() error {
|
|
|
|
return func() error {
|
|
|
|
commit := self.getSelectedLocalCommit()
|
|
|
|
if commit == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return callback(commit)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) Context() types.Context {
|
2022-01-31 13:20:28 +02:00
|
|
|
return self.context
|
2022-01-16 05:46:53 +02:00
|
|
|
}
|
2022-01-30 11:03:08 +02:00
|
|
|
|
|
|
|
func (self *LocalCommitsController) newBranch(commit *models.Commit) error {
|
|
|
|
return self.refsHelper.NewBranch(commit.RefName(), commit.Description(), "")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) copy(commit *models.Commit) error {
|
2022-01-31 13:20:28 +02:00
|
|
|
return self.cherryPickHelper.Copy(commit, self.model.Commits, self.context)
|
2022-01-30 11:03:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) copyRange(*models.Commit) error {
|
2022-01-31 13:20:28 +02:00
|
|
|
return self.cherryPickHelper.CopyRange(self.context.GetPanelState().GetSelectedLineIdx(), self.model.Commits, self.context)
|
2022-01-30 11:03:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LocalCommitsController) paste() error {
|
|
|
|
return self.cherryPickHelper.Paste()
|
|
|
|
}
|