1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-12-01 22:52:01 +02:00

logging durations and more stuff

This commit is contained in:
Jesse Duffield
2018-06-02 08:35:49 +10:00
parent a555a75565
commit 103a6fd219
10 changed files with 73 additions and 93 deletions

View File

@@ -1,18 +1,6 @@
// lots of this has been directly ported from one of the example files, will brush up later
// Copyright 2014 The gocui Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
// "io"
// "io/ioutil"
// "strings"
"fmt"
"github.com/jroimartin/gocui"
@@ -41,34 +29,36 @@ func getSelectedBranch(v *gocui.View) Branch {
return state.Branches[lineNumber]
}
// may want to standardise how these select methods work
func handleBranchSelect(g *gocui.Gui, v *gocui.View) error {
renderString(g, "options", "space: checkout, f: force checkout")
if len(state.Branches) == 0 {
return renderString(g, "main", "No branches for this repo")
}
// may want to standardise how these select methods work
lineNumber := getItemPosition(v)
branch := state.Branches[lineNumber]
diff, _ := getBranchDiff(branch.Name, branch.BaseBranch)
if err := renderString(g, "main", diff); err != nil {
return err
}
go func() {
lineNumber := getItemPosition(v)
branch := state.Branches[lineNumber]
diff, _ := getBranchDiff(branch.Name, branch.BaseBranch)
renderString(g, "main", diff)
}()
return nil
}
// refreshStatus is called at the end of this because that's when we can
// be sure there is a state.Branches array to pick the current branch from
func refreshBranches(g *gocui.Gui) error {
v, err := g.View("branches")
if err != nil {
panic(err)
}
state.Branches = getGitBranches()
v.Clear()
for _, branch := range state.Branches {
fmt.Fprintln(v, branch.DisplayString)
}
resetOrigin(v)
refreshStatus(g)
g.Update(func(g *gocui.Gui) error {
v, err := g.View("branches")
if err != nil {
panic(err)
}
state.Branches = getGitBranches()
v.Clear()
for _, branch := range state.Branches {
fmt.Fprintln(v, branch.DisplayString)
}
resetOrigin(v)
return refreshStatus(g)
})
return nil
}