mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-11-26 09:00:57 +02:00
appease golangci
This commit is contained in:
parent
4de31da4be
commit
1337f6e76a
@ -128,7 +128,10 @@ func (app *App) Rebase() error {
|
||||
app.Log.Info("args: ", os.Args)
|
||||
|
||||
if strings.HasSuffix(os.Args[1], "git-rebase-todo") {
|
||||
ioutil.WriteFile(os.Args[1], []byte(os.Getenv("LAZYGIT_REBASE_TODO")), 0644)
|
||||
if err := ioutil.WriteFile(os.Args[1], []byte(os.Getenv("LAZYGIT_REBASE_TODO")), 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
} else if strings.HasSuffix(os.Args[1], ".git/COMMIT_EDITMSG") {
|
||||
// if we are rebasing and squashing, we'll see a COMMIT_EDITMSG
|
||||
// but in this case we don't need to edit it, so we'll just return
|
||||
|
@ -215,7 +215,7 @@ func (c *OSCommand) AppendLineToFile(filename, line string) error {
|
||||
|
||||
_, err = f.WriteString("\n" + line)
|
||||
if err != nil {
|
||||
errors.Wrap(err, 0)
|
||||
return errors.Wrap(err, 0)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -22,6 +22,13 @@ func (gui *Gui) getSelectedBranch() *commands.Branch {
|
||||
|
||||
// may want to standardise how these select methods work
|
||||
func (gui *Gui) handleBranchSelect(g *gocui.Gui, v *gocui.View) error {
|
||||
if gui.popupPanelFocused() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, err := gui.g.SetCurrentView(v.Name()); err != nil {
|
||||
return err
|
||||
}
|
||||
// This really shouldn't happen: there should always be a master branch
|
||||
if len(gui.State.Branches) == 0 {
|
||||
return gui.renderString(g, "main", gui.Tr.SLocalize("NoBranchesThisRepo"))
|
||||
|
@ -49,8 +49,7 @@ func (gui *Gui) changeContext(viewName, context string) error {
|
||||
}
|
||||
}
|
||||
gui.State.Contexts[viewName] = context
|
||||
gui.setMainTitle()
|
||||
return nil
|
||||
return gui.setMainTitle()
|
||||
}
|
||||
|
||||
func (gui *Gui) setInitialContexts() error {
|
||||
|
@ -27,6 +27,10 @@ func (gui *Gui) getSelectedFile(g *gocui.Gui) (*commands.File, error) {
|
||||
}
|
||||
|
||||
func (gui *Gui) handleFileSelect(g *gocui.Gui, v *gocui.View, alreadySelected bool) error {
|
||||
if _, err := gui.g.SetCurrentView(v.Name()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
file, err := gui.getSelectedFile(g)
|
||||
if err != nil {
|
||||
if err != gui.Errors.ErrNoFiles {
|
||||
@ -41,11 +45,6 @@ func (gui *Gui) handleFileSelect(g *gocui.Gui, v *gocui.View, alreadySelected bo
|
||||
|
||||
if file.HasMergeConflicts {
|
||||
return gui.refreshMergePanel()
|
||||
} else {
|
||||
// TODO: set title appropriately
|
||||
// if _, err := gui.g.SetViewOnBottom("merging"); err != nil {
|
||||
// return err
|
||||
// }
|
||||
}
|
||||
|
||||
content := gui.GitCommand.Diff(file, false)
|
||||
@ -62,7 +61,9 @@ func (gui *Gui) refreshFiles() error {
|
||||
selectedFile, _ := gui.getSelectedFile(gui.g)
|
||||
|
||||
filesView := gui.getFilesView()
|
||||
gui.refreshStateFiles()
|
||||
if err := gui.refreshStateFiles(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
gui.g.Update(func(g *gocui.Gui) error {
|
||||
|
||||
@ -346,12 +347,12 @@ func (gui *Gui) handleRefreshFiles(g *gocui.Gui, v *gocui.View) error {
|
||||
return gui.refreshFiles()
|
||||
}
|
||||
|
||||
func (gui *Gui) refreshStateFiles() {
|
||||
func (gui *Gui) refreshStateFiles() error {
|
||||
// get files to stage
|
||||
files := gui.GitCommand.GetStatusFiles()
|
||||
gui.State.Files = gui.GitCommand.MergeStatusFiles(gui.State.Files, files)
|
||||
gui.refreshSelectedLine(&gui.State.Panels.Files.SelectedLine, len(gui.State.Files))
|
||||
gui.updateWorkTreeState()
|
||||
return gui.updateWorkTreeState()
|
||||
}
|
||||
|
||||
func (gui *Gui) catSelectedFile(g *gocui.Gui) (string, error) {
|
||||
|
@ -248,6 +248,15 @@ func (gui *Gui) onFocusLost(v *gocui.View) error {
|
||||
if err := gui.renderListPanel(gui.getBranchesView(), gui.State.Branches); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if v.Name() == "main" {
|
||||
// if we have lost focus to a popup panel, that's okay
|
||||
if gui.popupPanelFocused() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := gui.changeContext("main", "normal"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
gui.Log.Info(v.Name() + " focus lost")
|
||||
return nil
|
||||
@ -521,7 +530,7 @@ func (gui *Gui) renderGlobalOptions() error {
|
||||
func (gui *Gui) goEvery(interval time.Duration, function func() error) {
|
||||
go func() {
|
||||
for range time.Tick(interval) {
|
||||
function()
|
||||
_ = function()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user