mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-23 00:39:13 +02:00
Switch git-todo-parser from fsmiamoto original repo to stefanhaller's fork
Sometimes it takes a while to get PRs accepted upstream, and this blocks our progress. Since I'm pretty much the only one making changes there anyway, it makes sense to point to my fork directly.
This commit is contained in:
91
vendor/github.com/stefanhaller/git-todo-parser/todo/write.go
generated
vendored
Normal file
91
vendor/github.com/stefanhaller/git-todo-parser/todo/write.go
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
package todo
|
||||
|
||||
import (
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Write(f io.Writer, todos []Todo, commentChar byte) error {
|
||||
for _, todo := range todos {
|
||||
if err := writeTodo(f, todo, commentChar); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func writeTodo(f io.Writer, todo Todo, commentChar byte) error {
|
||||
var sb strings.Builder
|
||||
if todo.Command != Comment {
|
||||
sb.WriteString(todo.Command.String())
|
||||
}
|
||||
|
||||
switch todo.Command {
|
||||
case NoOp:
|
||||
|
||||
case Comment:
|
||||
sb.WriteByte(commentChar)
|
||||
sb.WriteString(todo.Comment)
|
||||
|
||||
case Break:
|
||||
|
||||
case Label:
|
||||
fallthrough
|
||||
case Reset:
|
||||
sb.WriteByte(' ')
|
||||
sb.WriteString(todo.Label)
|
||||
|
||||
case Exec:
|
||||
sb.WriteByte(' ')
|
||||
sb.WriteString(todo.ExecCommand)
|
||||
|
||||
case Merge:
|
||||
sb.WriteByte(' ')
|
||||
if todo.Commit != "" {
|
||||
sb.WriteString(todo.Flag)
|
||||
sb.WriteByte(' ')
|
||||
sb.WriteString(todo.Commit)
|
||||
sb.WriteByte(' ')
|
||||
}
|
||||
sb.WriteString(todo.Label)
|
||||
if todo.Msg != "" {
|
||||
sb.WriteString(" # ")
|
||||
sb.WriteString(todo.Msg)
|
||||
}
|
||||
|
||||
case Fixup:
|
||||
sb.WriteByte(' ')
|
||||
if todo.Flag != "" {
|
||||
sb.WriteString(todo.Flag)
|
||||
sb.WriteByte(' ')
|
||||
}
|
||||
sb.WriteString(todo.Commit)
|
||||
|
||||
case UpdateRef:
|
||||
sb.WriteByte(' ')
|
||||
sb.WriteString(todo.Ref)
|
||||
|
||||
case Pick:
|
||||
fallthrough
|
||||
case Revert:
|
||||
fallthrough
|
||||
case Edit:
|
||||
fallthrough
|
||||
case Reword:
|
||||
fallthrough
|
||||
case Squash:
|
||||
fallthrough
|
||||
case Drop:
|
||||
sb.WriteByte(' ')
|
||||
sb.WriteString(todo.Commit)
|
||||
if todo.Msg != "" {
|
||||
sb.WriteByte(' ')
|
||||
sb.WriteString(todo.Msg)
|
||||
}
|
||||
}
|
||||
|
||||
sb.WriteByte('\n')
|
||||
_, err := f.Write([]byte(sb.String()))
|
||||
return err
|
||||
}
|
Reference in New Issue
Block a user