mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +02:00
add keybinding to create new branch off of commit
retain focus in commits panel surface prompt errors better description
This commit is contained in:
parent
be658e7d64
commit
db826b3c87
9 changed files with 47 additions and 3 deletions
|
@ -144,6 +144,7 @@
|
||||||
<kbd>v</kbd>: paste commits (cherry-pick)
|
<kbd>v</kbd>: paste commits (cherry-pick)
|
||||||
<kbd>enter</kbd>: view commit's files
|
<kbd>enter</kbd>: view commit's files
|
||||||
<kbd>space</kbd>: checkout commit
|
<kbd>space</kbd>: checkout commit
|
||||||
|
<kbd>n</kbd>: create new branch off of commit
|
||||||
<kbd>T</kbd>: tag commit
|
<kbd>T</kbd>: tag commit
|
||||||
<kbd>ctrl+r</kbd>: reset cherry-picked (copied) commits selection
|
<kbd>ctrl+r</kbd>: reset cherry-picked (copied) commits selection
|
||||||
<kbd>,</kbd>: previous page
|
<kbd>,</kbd>: previous page
|
||||||
|
|
|
@ -144,6 +144,7 @@
|
||||||
<kbd>v</kbd>: plak commits (cherry-pick)
|
<kbd>v</kbd>: plak commits (cherry-pick)
|
||||||
<kbd>enter</kbd>: bekijk gecommite bestanden
|
<kbd>enter</kbd>: bekijk gecommite bestanden
|
||||||
<kbd>space</kbd>: checkout commit
|
<kbd>space</kbd>: checkout commit
|
||||||
|
<kbd>n</kbd>: create new branch off of commit
|
||||||
<kbd>T</kbd>: tag commit
|
<kbd>T</kbd>: tag commit
|
||||||
<kbd>ctrl+r</kbd>: reset cherry-picked (gecopieerde) commits selectie
|
<kbd>ctrl+r</kbd>: reset cherry-picked (gecopieerde) commits selectie
|
||||||
<kbd>,</kbd>: vorige pagina
|
<kbd>,</kbd>: vorige pagina
|
||||||
|
|
|
@ -144,6 +144,7 @@
|
||||||
<kbd>v</kbd>: paste commits (cherry-pick)
|
<kbd>v</kbd>: paste commits (cherry-pick)
|
||||||
<kbd>enter</kbd>: view commit's files
|
<kbd>enter</kbd>: view commit's files
|
||||||
<kbd>space</kbd>: checkout commit
|
<kbd>space</kbd>: checkout commit
|
||||||
|
<kbd>n</kbd>: create new branch off of commit
|
||||||
<kbd>T</kbd>: tag commit
|
<kbd>T</kbd>: tag commit
|
||||||
<kbd>ctrl+r</kbd>: reset cherry-picked (copied) commits selection
|
<kbd>ctrl+r</kbd>: reset cherry-picked (copied) commits selection
|
||||||
<kbd>,</kbd>: previous page
|
<kbd>,</kbd>: previous page
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
// Commit : A git commit
|
// Commit : A git commit
|
||||||
type Commit struct {
|
type Commit struct {
|
||||||
Sha string
|
Sha string
|
||||||
|
@ -18,3 +20,7 @@ func (c *Commit) ShortSha() string {
|
||||||
}
|
}
|
||||||
return c.Sha[:8]
|
return c.Sha[:8]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Commit) NameWithSha() string {
|
||||||
|
return fmt.Sprintf("%s %s", c.Sha[:7], c.Name)
|
||||||
|
}
|
||||||
|
|
|
@ -401,8 +401,8 @@ func (c *GitCommand) ResetToCommit(sha string, strength string, options RunComma
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBranch create new branch
|
// NewBranch create new branch
|
||||||
func (c *GitCommand) NewBranch(name string, baseBranch string) error {
|
func (c *GitCommand) NewBranch(name string, base string) error {
|
||||||
return c.OSCommand.RunCommand("git checkout -b %s %s", name, baseBranch)
|
return c.OSCommand.RunCommand("git checkout -b %s %s", name, base)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CurrentBranchName get the current branch name and displayname.
|
// CurrentBranchName get the current branch name and displayname.
|
||||||
|
|
|
@ -771,3 +771,27 @@ func (gui *Gui) handleClipboardCopyCommit(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
|
||||||
return gui.OSCommand.CopyToClipboard(commit.Sha)
|
return gui.OSCommand.CopyToClipboard(commit.Sha)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) handleNewBranchOffCommit() error {
|
||||||
|
commit := gui.getSelectedCommit()
|
||||||
|
if commit == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
message := gui.Tr.TemplateLocalize(
|
||||||
|
"NewBranchNameBranchOff",
|
||||||
|
Teml{
|
||||||
|
"branchName": commit.NameWithSha(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
return gui.prompt(gui.getCommitsView(), message, "", func(response string) error {
|
||||||
|
if err := gui.GitCommand.NewBranch(response, commit.Sha); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
gui.State.Panels.Commits.SelectedLine = 0
|
||||||
|
gui.State.Panels.Branches.SelectedLine = 0
|
||||||
|
|
||||||
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ func (gui *Gui) wrappedPromptConfirmationFunction(function func(string) error, r
|
||||||
|
|
||||||
if function != nil {
|
if function != nil {
|
||||||
if err := function(v.Buffer()); err != nil {
|
if err := function(v.Buffer()); err != nil {
|
||||||
return err
|
return gui.surfaceError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -775,6 +775,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||||
Handler: gui.handleCheckoutCommit,
|
Handler: gui.handleCheckoutCommit,
|
||||||
Description: gui.Tr.SLocalize("checkoutCommit"),
|
Description: gui.Tr.SLocalize("checkoutCommit"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "commits",
|
||||||
|
Contexts: []string{"branch-commits"},
|
||||||
|
Key: gui.getKey("universal.new"),
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.wrappedHandler(gui.handleNewBranchOffCommit),
|
||||||
|
Description: gui.Tr.SLocalize("createNewBranchFromCommit"),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ViewName: "commits",
|
ViewName: "commits",
|
||||||
Contexts: []string{"branch-commits"},
|
Contexts: []string{"branch-commits"},
|
||||||
|
|
|
@ -1167,6 +1167,9 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "UnstageLinesPrompt",
|
ID: "UnstageLinesPrompt",
|
||||||
Other: "Are you sure you want to delete the selected lines (git reset)? It is irreversible.\nTo disable this dialogue set the config key of 'gui.skipUnstageLineWarning' to true",
|
Other: "Are you sure you want to delete the selected lines (git reset)? It is irreversible.\nTo disable this dialogue set the config key of 'gui.skipUnstageLineWarning' to true",
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "createNewBranchFromCommit",
|
||||||
|
Other: "create new branch off of commit",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue