mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-06 03:53:59 +02:00
checks for if we're in a normal working tree state
This commit is contained in:
parent
1fc120de2d
commit
0ffccbd3ee
@ -64,6 +64,10 @@ func (gui *Gui) handleCheckoutCommitFile(g *gocui.Gui, v *gocui.View) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleDiscardOldFileChange(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleDiscardOldFileChange(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
if ok, err := gui.validateNormalWorkingTreeState(); !ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
fileName := gui.State.CommitFiles[gui.State.Panels.CommitFiles.SelectedLine].Name
|
fileName := gui.State.CommitFiles[gui.State.Panels.CommitFiles.SelectedLine].Name
|
||||||
|
|
||||||
return gui.createConfirmationPanel(gui.g, v, gui.Tr.SLocalize("DiscardFileChangesTitle"), gui.Tr.SLocalize("DiscardFileChangesPrompt"), func(g *gocui.Gui, v *gocui.View) error {
|
return gui.createConfirmationPanel(gui.g, v, gui.Tr.SLocalize("DiscardFileChangesTitle"), gui.Tr.SLocalize("DiscardFileChangesPrompt"), func(g *gocui.Gui, v *gocui.View) error {
|
||||||
@ -110,6 +114,10 @@ func (gui *Gui) handleOpenOldCommitFile(g *gocui.Gui, v *gocui.View) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
if ok, err := gui.validateNormalWorkingTreeState(); !ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
commitFile := gui.getSelectedCommitFile(g)
|
commitFile := gui.getSelectedCommitFile(g)
|
||||||
if commitFile == nil {
|
if commitFile == nil {
|
||||||
return gui.renderString(g, "commitFiles", gui.Tr.SLocalize("NoCommiteFiles"))
|
return gui.renderString(g, "commitFiles", gui.Tr.SLocalize("NoCommiteFiles"))
|
||||||
@ -157,6 +165,10 @@ func (gui *Gui) createPatchManager() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleEnterCommitFile(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleEnterCommitFile(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
if ok, err := gui.validateNormalWorkingTreeState(); !ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
commitFile := gui.getSelectedCommitFile(g)
|
commitFile := gui.getSelectedCommitFile(g)
|
||||||
if commitFile == nil {
|
if commitFile == nil {
|
||||||
return gui.renderString(g, "commitFiles", gui.Tr.SLocalize("NoCommiteFiles"))
|
return gui.renderString(g, "commitFiles", gui.Tr.SLocalize("NoCommiteFiles"))
|
||||||
|
@ -54,7 +54,9 @@ func (gui *Gui) getPatchCommitIndex() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleDeletePatchFromCommit() error {
|
func (gui *Gui) handleDeletePatchFromCommit() error {
|
||||||
// TODO: deal with when we're already rebasing
|
if ok, err := gui.validateNormalWorkingTreeState(); !ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error {
|
return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error {
|
||||||
commitIndex := gui.getPatchCommitIndex()
|
commitIndex := gui.getPatchCommitIndex()
|
||||||
@ -64,7 +66,9 @@ func (gui *Gui) handleDeletePatchFromCommit() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleMovePatchToSelectedCommit() error {
|
func (gui *Gui) handleMovePatchToSelectedCommit() error {
|
||||||
// TODO: deal with when we're already rebasing
|
if ok, err := gui.validateNormalWorkingTreeState(); !ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error {
|
return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error {
|
||||||
commitIndex := gui.getPatchCommitIndex()
|
commitIndex := gui.getPatchCommitIndex()
|
||||||
@ -73,8 +77,17 @@ func (gui *Gui) handleMovePatchToSelectedCommit() error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) validateNormalWorkingTreeState() (bool, error) {
|
||||||
|
if gui.State.WorkingTreeState != "normal" {
|
||||||
|
return false, gui.createErrorPanel(gui.g, gui.Tr.SLocalize("CantPatchWhileRebasingError"))
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) handlePullPatchIntoWorkingTree() error {
|
func (gui *Gui) handlePullPatchIntoWorkingTree() error {
|
||||||
// TODO: deal with when we're already rebasing
|
if ok, err := gui.validateNormalWorkingTreeState(); !ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error {
|
return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error {
|
||||||
commitIndex := gui.getPatchCommitIndex()
|
commitIndex := gui.getPatchCommitIndex()
|
||||||
|
@ -800,6 +800,9 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
|||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "DiscardPatchConfirm",
|
ID: "DiscardPatchConfirm",
|
||||||
Other: "You can only build a patch from one commit at a time. Discard current patch?",
|
Other: "You can only build a patch from one commit at a time. Discard current patch?",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "CantPatchWhileRebasingError",
|
||||||
|
Other: "You cannot build a patch or run patch commands while in a merging or rebasing state",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "toggleAddToPatch",
|
ID: "toggleAddToPatch",
|
||||||
Other: "toggle file included in patch",
|
Other: "toggle file included in patch",
|
||||||
|
Loading…
Reference in New Issue
Block a user