1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-05 23:50:39 +03:00
Files
lazygit/pkg/utils/rebaseTodo.go
Stefan Haller 120dd1530a Make EditRebaseTodo more robust
It used to work on the assumption that rebasing commits in lazygit's model
correspond one-to-one to lines in the git-rebase-todo file, which isn't
necessarily true (e.g. when users use "git rebase --edit-todo" at the custom
command prompt and add a "break" between lines).
2023-04-15 08:36:03 +02:00

35 lines
541 B
Go

package utils
import (
"os"
"github.com/fsmiamoto/git-todo-parser/todo"
)
func ReadRebaseTodoFile(fileName string) ([]todo.Todo, error) {
f, err := os.Open(fileName)
if err != nil {
return nil, err
}
todos, err := todo.Parse(f)
err2 := f.Close()
if err == nil {
err = err2
}
return todos, err
}
func WriteRebaseTodoFile(fileName string, todos []todo.Todo) error {
f, err := os.Create(fileName)
if err != nil {
return err
}
err = todo.Write(f, todos)
err2 := f.Close()
if err == nil {
err = err2
}
return err
}