1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-01 13:17:53 +02:00

Update README.md

This commit is contained in:
Jesse Duffield 2018-06-09 19:30:59 +10:00
parent d413d4319f
commit 08174ca848
4 changed files with 28 additions and 2 deletions

5
README.md Normal file
View File

@ -0,0 +1,5 @@
# lazygit
simple terminal UI for git commands
![Gif](https://image.ibb.co/nxyY58/shortone.gif)

View File

@ -24,6 +24,16 @@ func handleForceCheckout(g *gocui.Gui, v *gocui.View) error {
}, nil)
}
func handleCheckoutByName(g *gocui.Gui, v *gocui.View) error {
createPromptPanel(g, v, "Branch Name:", func(g *gocui.Gui, v *gocui.View) error {
if output, err := gitCheckout(trimmedContent(v), false); err != nil {
return createErrorPanel(g, output)
}
return refreshSidePanels(g)
})
return nil
}
func handleNewBranch(g *gocui.Gui, v *gocui.View) error {
branch := state.Branches[0]
createPromptPanel(g, v, "New Branch Name (Branch is off of "+branch.Name+")", func(g *gocui.Gui, v *gocui.View) error {
@ -31,7 +41,7 @@ func handleNewBranch(g *gocui.Gui, v *gocui.View) error {
return createErrorPanel(g, output)
}
refreshSidePanels(g)
return handleCommitSelect(g, v)
return handleBranchSelect(g, v)
})
return nil
}
@ -59,6 +69,7 @@ func renderBranchesOptions(g *gocui.Gui) error {
"space": "checkout",
"f": "force checkout",
"m": "merge",
"c": "checkout by name",
})
}

View File

@ -165,7 +165,14 @@ func getGitBranches() []Branch {
return branches
}
rawString, _ := runDirectCommand(getBranchesCommand)
for i, line := range splitLines(rawString) {
branchLines := splitLines(rawString)
if len(branchLines) == 0 {
// sometimes the getBranchesCommand command returns nothing, in which case
// we assume you've just init'd or cloned the repo and you've got master
// checked out
branches = append(branches, branchFromLine(" *\tmaster", 0))
}
for i, line := range branchLines {
branches = append(branches, branchFromLine(line, i))
}
return branches

3
gui.go
View File

@ -146,6 +146,9 @@ func keybindings(g *gocui.Gui) error {
if err := g.SetKeybinding("branches", gocui.KeySpace, gocui.ModNone, handleBranchPress); err != nil {
return err
}
if err := g.SetKeybinding("branches", 'c', gocui.ModNone, handleCheckoutByName); err != nil {
return err
}
if err := g.SetKeybinding("branches", 'F', gocui.ModNone, handleForceCheckout); err != nil {
return err
}