1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-11-24 08:52:21 +02:00

Bump git-todo-parser

This commit is contained in:
Gustavo Krieger 2023-07-02 00:52:25 -03:00
parent cff9850374
commit 87fe30d50d
8 changed files with 19 additions and 21 deletions

2
go.mod
View File

@ -9,7 +9,7 @@ require (
github.com/cli/safeexec v1.0.0
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
github.com/creack/pty v1.1.11
github.com/fsmiamoto/git-todo-parser v0.0.4
github.com/fsmiamoto/git-todo-parser v0.0.5
github.com/fsnotify/fsnotify v1.4.7
github.com/gdamore/tcell/v2 v2.6.0
github.com/go-errors/errors v1.4.2

4
go.sum
View File

@ -28,8 +28,8 @@ github.com/fatih/color v1.7.1-0.20180516100307-2d684516a886/go.mod h1:Zm6kSWBoL9
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/fsmiamoto/git-todo-parser v0.0.4 h1:fzcGaoAFDHWzJRKw//CSZFrXucsLKplIvOSab3FtWWM=
github.com/fsmiamoto/git-todo-parser v0.0.4/go.mod h1:B+AgTbNE2BARvJqzXygThzqxLIaEWvwr2sxKYYb0Fas=
github.com/fsmiamoto/git-todo-parser v0.0.5 h1:Bhzd/vz/6Qm3udfkd6NO9fWfD3TpwR9ucp3N75/J5I8=
github.com/fsmiamoto/git-todo-parser v0.0.5/go.mod h1:B+AgTbNE2BARvJqzXygThzqxLIaEWvwr2sxKYYb0Fas=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=

View File

@ -304,7 +304,7 @@ func (self *CommitLoader) getInteractiveRebasingCommits() ([]*models.Commit, err
commits := []*models.Commit{}
todos, err := todo.Parse(bytes.NewBuffer(bytesContent))
todos, err := todo.Parse(bytes.NewBuffer(bytesContent), '#')
if err != nil {
self.Log.Error(fmt.Sprintf("error occurred while parsing git-rebase-todo file: %s", err.Error()))
return nil, nil
@ -346,7 +346,7 @@ func (self *CommitLoader) getConflictedCommit(todos []todo.Todo) string {
return ""
}
doneTodos, err := todo.Parse(bytes.NewBuffer(bytesContent))
doneTodos, err := todo.Parse(bytes.NewBuffer(bytesContent), '#')
if err != nil {
self.Log.Error(fmt.Sprintf("error occurred while parsing rebase-merge/done file: %s", err.Error()))
return ""

View File

@ -42,7 +42,7 @@ func ReadRebaseTodoFile(fileName string) ([]todo.Todo, error) {
return nil, err
}
todos, err := todo.Parse(f)
todos, err := todo.Parse(f, '#')
err2 := f.Close()
if err == nil {
err = err2
@ -55,7 +55,7 @@ func WriteRebaseTodoFile(fileName string, todos []todo.Todo) error {
if err != nil {
return err
}
err = todo.Write(f, todos)
err = todo.Write(f, todos, '#')
err2 := f.Close()
if err == nil {
err = err2

View File

@ -16,7 +16,7 @@ var (
ErrMissingRef = errors.New("missing ref")
)
func Parse(f io.Reader) ([]Todo, error) {
func Parse(f io.Reader, commentChar byte) ([]Todo, error) {
var result []Todo
scanner := bufio.NewScanner(f)
@ -30,7 +30,7 @@ func Parse(f io.Reader) ([]Todo, error) {
continue
}
cmd, err := parseLine(line)
cmd, err := parseLine(line, commentChar)
if err != nil {
return nil, fmt.Errorf("failed to parse line %q: %w", line, err)
}
@ -45,12 +45,12 @@ func Parse(f io.Reader) ([]Todo, error) {
return result, nil
}
func parseLine(line string) (Todo, error) {
func parseLine(line string, commentChar byte) (Todo, error) {
var todo Todo
if strings.HasPrefix(line, CommentChar) {
if line[0] == commentChar {
todo.Command = Comment
todo.Comment = strings.TrimLeft(line, CommentChar)
todo.Comment = line[1:]
return todo, nil
}
@ -143,8 +143,8 @@ func parseLine(line string) (Todo, error) {
todo.Commit = fields[0]
fields = fields[1:]
// Trim # and whitespace
todo.Msg = strings.TrimPrefix(strings.Join(fields, " "), CommentChar+" ")
// Trim comment char and whitespace
todo.Msg = strings.TrimPrefix(strings.Join(fields, " "), fmt.Sprintf("%c ", commentChar))
return todo, nil
}

View File

@ -23,8 +23,6 @@ const (
Comment
)
const CommentChar = "#"
type Todo struct {
Command TodoCommand
Commit string

View File

@ -5,9 +5,9 @@ import (
"strings"
)
func Write(f io.Writer, todos []Todo) error {
func Write(f io.Writer, todos []Todo, commentChar byte) error {
for _, todo := range todos {
if err := writeTodo(f, todo); err != nil {
if err := writeTodo(f, todo, commentChar); err != nil {
return err
}
}
@ -15,7 +15,7 @@ func Write(f io.Writer, todos []Todo) error {
return nil
}
func writeTodo(f io.Writer, todo Todo) error {
func writeTodo(f io.Writer, todo Todo, commentChar byte) error {
var sb strings.Builder
if todo.Command != Comment {
sb.WriteString(todo.Command.String())
@ -26,7 +26,7 @@ func writeTodo(f io.Writer, todo Todo) error {
return nil
case Comment:
sb.WriteString(CommentChar)
sb.WriteByte(commentChar)
sb.WriteString(todo.Comment)
case Break:

2
vendor/modules.txt vendored
View File

@ -30,7 +30,7 @@ github.com/emirpasic/gods/utils
# github.com/fatih/color v1.9.0
## explicit; go 1.13
github.com/fatih/color
# github.com/fsmiamoto/git-todo-parser v0.0.4
# github.com/fsmiamoto/git-todo-parser v0.0.5
## explicit; go 1.13
github.com/fsmiamoto/git-todo-parser/todo
# github.com/fsnotify/fsnotify v1.4.7