1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-09 09:22:48 +03:00

Allow moving update-ref todos up/down

This commit is contained in:
Stefan Haller
2024-03-16 15:51:14 +01:00
parent e5fa9e1c4a
commit bd975a8dcb
6 changed files with 132 additions and 13 deletions

View File

@@ -10,7 +10,8 @@ import (
)
type Todo struct {
Sha string
Sha string // for todos that have one, e.g. pick, drop, fixup, etc.
Ref string // for update-ref todos
Action todo.TodoCommand
}
@@ -130,8 +131,11 @@ func moveTodoUp(todos []todo.Todo, todoToMove Todo) ([]todo.Todo, error) {
_, sourceIdx, ok := lo.FindIndexOf(todos, func(t todo.Todo) bool {
// Comparing just the sha is not enough; we need to compare both the
// action and the sha, as the sha could appear multiple times (e.g. in a
// pick and later in a merge)
return t.Command == todoToMove.Action && equalShas(t.Commit, todoToMove.Sha)
// pick and later in a merge). For update-ref todos we also must compare
// the Ref.
return t.Command == todoToMove.Action &&
equalShas(t.Commit, todoToMove.Sha) &&
t.Ref == todoToMove.Ref
})
if !ok {