1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-28 16:02:01 +03:00

move soft reset keybinding into reset options

This commit is contained in:
Jesse Duffield
2019-03-18 21:40:32 +11:00
parent f502f75e1f
commit acfc961909
6 changed files with 28 additions and 53 deletions

View File

@ -905,3 +905,8 @@ func (c *GitCommand) RemoveUntrackedFiles() error {
func (c *GitCommand) ResetHardHead() error { func (c *GitCommand) ResetHardHead() error {
return c.OSCommand.RunCommand("git reset --hard HEAD") return c.OSCommand.RunCommand("git reset --hard HEAD")
} }
// ResetSoftHead runs `git reset --soft HEAD`
func (c *GitCommand) ResetSoftHead() error {
return c.OSCommand.RunCommand("git reset --soft HEAD")
}

View File

@ -472,19 +472,6 @@ func (gui *Gui) anyFilesWithMergeConflicts() bool {
return false return false
} }
func (gui *Gui) handleSoftReset(g *gocui.Gui, v *gocui.View) error {
return gui.createConfirmationPanel(g, v, gui.Tr.SLocalize("SoftReset"), gui.Tr.SLocalize("ConfirmSoftReset"), func(g *gocui.Gui, v *gocui.View) error {
if err := gui.GitCommand.SoftReset("HEAD^"); err != nil {
return gui.createErrorPanel(g, err.Error())
}
if err := gui.refreshCommits(gui.g); err != nil {
return err
}
return gui.refreshFiles()
}, nil)
}
type discardOption struct { type discardOption struct {
handler func(fileName *commands.File) error handler func(fileName *commands.File) error
description string description string
@ -552,7 +539,7 @@ func (gui *Gui) handleCreateDiscardMenu(g *gocui.Gui, v *gocui.View) error {
return gui.createMenu(file.Name, options, handleMenuPress) return gui.createMenu(file.Name, options, handleMenuPress)
} }
func (gui *Gui) handleResetAndClean(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) handleCreateResetMenu(g *gocui.Gui, v *gocui.View) error {
options := []*discardAllOption{ options := []*discardAllOption{
{ {
description: gui.Tr.SLocalize("discardAllChangesToAllFiles"), description: gui.Tr.SLocalize("discardAllChangesToAllFiles"),
@ -575,6 +562,13 @@ func (gui *Gui) handleResetAndClean(g *gocui.Gui, v *gocui.View) error {
return gui.GitCommand.RemoveUntrackedFiles() return gui.GitCommand.RemoveUntrackedFiles()
}, },
}, },
{
description: gui.Tr.SLocalize("softReset"),
command: "git reset --soft HEAD",
handler: func() error {
return gui.GitCommand.ResetSoftHead()
},
},
{ {
description: gui.Tr.SLocalize("hardReset"), description: gui.Tr.SLocalize("hardReset"),
command: "git reset --hard HEAD", command: "git reset --hard HEAD",

View File

@ -208,12 +208,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Modifier: gocui.ModNone, Modifier: gocui.ModNone,
Handler: gui.handleStashSave, Handler: gui.handleStashSave,
Description: gui.Tr.SLocalize("stashFiles"), Description: gui.Tr.SLocalize("stashFiles"),
}, {
ViewName: "files",
Key: 's',
Modifier: gocui.ModNone,
Handler: gui.handleSoftReset,
Description: gui.Tr.SLocalize("softReset"),
}, { }, {
ViewName: "files", ViewName: "files",
Key: 'a', Key: 'a',
@ -230,8 +224,8 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
ViewName: "files", ViewName: "files",
Key: 'D', Key: 'D',
Modifier: gocui.ModNone, Modifier: gocui.ModNone,
Handler: gui.handleResetAndClean, Handler: gui.handleCreateResetMenu,
Description: gui.Tr.SLocalize("resetHard"), Description: gui.Tr.SLocalize("viewResetOptions"),
}, { }, {
ViewName: "files", ViewName: "files",
Key: gocui.KeyEnter, Key: gocui.KeyEnter,

View File

@ -388,9 +388,6 @@ func addDutch(i18nObject *i18n.Bundle) error {
}, &i18n.Message{ }, &i18n.Message{
ID: "refreshFiles", ID: "refreshFiles",
Other: `refresh bestanden`, Other: `refresh bestanden`,
}, &i18n.Message{
ID: "resetHard",
Other: `harde reset and verwijderen ongevolgde bestanden`,
}, &i18n.Message{ }, &i18n.Message{
ID: "mergeIntoCurrentBranch", ID: "mergeIntoCurrentBranch",
Other: `merge in met huidige checked out branch`, Other: `merge in met huidige checked out branch`,
@ -471,13 +468,7 @@ func addDutch(i18nObject *i18n.Bundle) error {
Other: "Normal", Other: "Normal",
}, &i18n.Message{ }, &i18n.Message{
ID: "softReset", ID: "softReset",
Other: "soft reset to last commit", Other: "soft reset",
}, &i18n.Message{
ID: "SoftReset",
Other: "Soft reset",
}, &i18n.Message{
ID: "ConfirmSoftReset",
Other: "Are you sure you want to `reset --soft HEAD^`? The changes in your topmost commit will be placed in your working tree",
}, &i18n.Message{ }, &i18n.Message{
ID: "CantRebaseOntoSelf", ID: "CantRebaseOntoSelf",
Other: "You cannot rebase a branch onto itself", Other: "You cannot rebase a branch onto itself",
@ -697,6 +688,9 @@ func addDutch(i18nObject *i18n.Bundle) error {
}, &i18n.Message{ }, &i18n.Message{
ID: "discardUntrackedFiles", ID: "discardUntrackedFiles",
Other: "discard untracked files", Other: "discard untracked files",
}, &i18n.Message{
ID: "viewResetOptions",
Other: `view reset options`,
}, &i18n.Message{ }, &i18n.Message{
ID: "hardReset", ID: "hardReset",
Other: "hard reset", Other: "hard reset",

View File

@ -102,9 +102,6 @@ func addEnglish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{ }, &i18n.Message{
ID: "stashFiles", ID: "stashFiles",
Other: "stash files", Other: "stash files",
}, &i18n.Message{
ID: "softReset",
Other: "soft reset to last commit",
}, &i18n.Message{ }, &i18n.Message{
ID: "open", ID: "open",
Other: "open", Other: "open",
@ -181,11 +178,8 @@ func addEnglish(i18nObject *i18n.Bundle) error {
ID: "FileNoMergeCons", ID: "FileNoMergeCons",
Other: "This file has no inline merge conflicts", Other: "This file has no inline merge conflicts",
}, &i18n.Message{ }, &i18n.Message{
ID: "SoftReset", ID: "softReset",
Other: "Soft reset", Other: "soft reset",
}, &i18n.Message{
ID: "ConfirmSoftReset",
Other: "Are you sure you want to `reset --soft HEAD^`? The changes in your topmost commit will be placed in your working tree",
}, &i18n.Message{ }, &i18n.Message{
ID: "SureTo", ID: "SureTo",
Other: "Are you sure you want to {{.deleteVerb}} {{.fileName}} (you will lose your changes)?", Other: "Are you sure you want to {{.deleteVerb}} {{.fileName}} (you will lose your changes)?",
@ -453,9 +447,6 @@ func addEnglish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{ }, &i18n.Message{
ID: "refreshFiles", ID: "refreshFiles",
Other: `refresh files`, Other: `refresh files`,
}, &i18n.Message{
ID: "resetHard",
Other: `reset hard and remove untracked files`,
}, &i18n.Message{ }, &i18n.Message{
ID: "mergeIntoCurrentBranch", ID: "mergeIntoCurrentBranch",
Other: `merge into currently checked out branch`, Other: `merge into currently checked out branch`,
@ -723,6 +714,9 @@ func addEnglish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{ }, &i18n.Message{
ID: "hardReset", ID: "hardReset",
Other: "hard reset", Other: "hard reset",
}, &i18n.Message{
ID: "viewResetOptions",
Other: `view reset options`,
}, },
) )
} }

View File

@ -377,9 +377,6 @@ func addPolish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{ }, &i18n.Message{
ID: "refreshFiles", ID: "refreshFiles",
Other: `odśwież pliki`, Other: `odśwież pliki`,
}, &i18n.Message{
ID: "resetHard",
Other: `zresetuj twardo i usuń niepotwierdzone pliki`,
}, &i18n.Message{ }, &i18n.Message{
ID: "mergeIntoCurrentBranch", ID: "mergeIntoCurrentBranch",
Other: `scal do obecnej gałęzi`, Other: `scal do obecnej gałęzi`,
@ -457,13 +454,7 @@ func addPolish(i18nObject *i18n.Bundle) error {
Other: "Normal", Other: "Normal",
}, &i18n.Message{ }, &i18n.Message{
ID: "softReset", ID: "softReset",
Other: "soft reset to last commit", Other: "soft reset",
}, &i18n.Message{
ID: "SoftReset",
Other: "Soft reset",
}, &i18n.Message{
ID: "ConfirmSoftReset",
Other: "Are you sure you want to `reset --soft HEAD^`? The changes in your topmost commit will be placed in your working tree",
}, &i18n.Message{ }, &i18n.Message{
ID: "SureSquashThisCommit", ID: "SureSquashThisCommit",
Other: "Are you sure you want to squash this commit into the commit below?", Other: "Are you sure you want to squash this commit into the commit below?",
@ -683,6 +674,9 @@ func addPolish(i18nObject *i18n.Bundle) error {
}, &i18n.Message{ }, &i18n.Message{
ID: "hardReset", ID: "hardReset",
Other: "hard reset", Other: "hard reset",
}, &i18n.Message{
ID: "viewResetOptions",
Other: `view reset options`,
}, },
) )
} }