mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-05 23:50:39 +03:00
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).
35 lines
541 B
Go
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
|
|
}
|