mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
Use errors.New instead of fmt.Errorf with no parameters (#3523)
This commit is contained in:
commit
b2ff09ec0c
4 changed files with 12 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
package oscommands
|
package oscommands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -86,7 +86,7 @@ func CopyDir(src string, dst string) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !si.IsDir() {
|
if !si.IsDir() {
|
||||||
return fmt.Errorf("source is not a directory")
|
return errors.New("source is not a directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = os.Stat(dst)
|
_, err = os.Stat(dst)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
type HistoryBuffer[T any] struct {
|
type HistoryBuffer[T any] struct {
|
||||||
maxSize int
|
maxSize int
|
||||||
|
@ -24,10 +26,10 @@ func (self *HistoryBuffer[T]) Push(item T) {
|
||||||
func (self *HistoryBuffer[T]) PeekAt(index int) (T, error) {
|
func (self *HistoryBuffer[T]) PeekAt(index int) (T, error) {
|
||||||
var item T
|
var item T
|
||||||
if len(self.items) == 0 {
|
if len(self.items) == 0 {
|
||||||
return item, fmt.Errorf("Buffer is empty")
|
return item, errors.New("Buffer is empty")
|
||||||
}
|
}
|
||||||
if len(self.items) <= index || index < -1 {
|
if len(self.items) <= index || index < -1 {
|
||||||
return item, fmt.Errorf("Index out of range")
|
return item, errors.New("Index out of range")
|
||||||
}
|
}
|
||||||
if index == -1 {
|
if index == -1 {
|
||||||
return item, nil
|
return item, nil
|
||||||
|
|
|
@ -2,6 +2,7 @@ package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"slices"
|
"slices"
|
||||||
|
@ -48,7 +49,7 @@ func EditRebaseTodo(filePath string, changes []TodoChange, commentChar byte) err
|
||||||
|
|
||||||
if matchCount < len(changes) {
|
if matchCount < len(changes) {
|
||||||
// Should never get here
|
// Should never get here
|
||||||
return fmt.Errorf("Some todos not found in git-rebase-todo")
|
return errors.New("Some todos not found in git-rebase-todo")
|
||||||
}
|
}
|
||||||
|
|
||||||
return WriteRebaseTodoFile(filePath, todos, commentChar)
|
return WriteRebaseTodoFile(filePath, todos, commentChar)
|
||||||
|
@ -197,7 +198,7 @@ func moveTodoUp(todos []todo.Todo, todoToMove Todo) ([]todo.Todo, error) {
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
// We expect callers to guard against this
|
// We expect callers to guard against this
|
||||||
return []todo.Todo{}, fmt.Errorf("Destination position for moving todo is out of range")
|
return []todo.Todo{}, errors.New("Destination position for moving todo is out of range")
|
||||||
}
|
}
|
||||||
|
|
||||||
destinationIdx := sourceIdx + 1 + skip
|
destinationIdx := sourceIdx + 1 + skip
|
||||||
|
|
|
@ -190,7 +190,7 @@ func walk(node *yaml.Node, path string, callback func(*yaml.Node, string) bool)
|
||||||
didChange := callback(node, path)
|
didChange := callback(node, path)
|
||||||
switch node.Kind {
|
switch node.Kind {
|
||||||
case yaml.DocumentNode:
|
case yaml.DocumentNode:
|
||||||
return false, fmt.Errorf("Unexpected document node in the middle of a yaml tree")
|
return false, errors.New("Unexpected document node in the middle of a yaml tree")
|
||||||
case yaml.MappingNode:
|
case yaml.MappingNode:
|
||||||
for i := 0; i < len(node.Content); i += 2 {
|
for i := 0; i < len(node.Content); i += 2 {
|
||||||
name := node.Content[i].Value
|
name := node.Content[i].Value
|
||||||
|
@ -219,7 +219,7 @@ func walk(node *yaml.Node, path string, callback func(*yaml.Node, string) bool)
|
||||||
case yaml.ScalarNode:
|
case yaml.ScalarNode:
|
||||||
// nothing to do
|
// nothing to do
|
||||||
case yaml.AliasNode:
|
case yaml.AliasNode:
|
||||||
return false, fmt.Errorf("Alias nodes are not supported")
|
return false, errors.New("Alias nodes are not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
return didChange, nil
|
return didChange, nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue