mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-23 22:50:41 +02:00
Fix amend to operation not working with non-HEAD merge commit
This commit is contained in:
parent
580818e935
commit
ef99e47d09
@ -235,7 +235,7 @@ func MoveFixupCommitDown(fileName string, originalHash string, fixupHash string,
|
|||||||
|
|
||||||
func moveFixupCommitDown(todos []todo.Todo, originalHash string, fixupHash string) ([]todo.Todo, error) {
|
func moveFixupCommitDown(todos []todo.Todo, originalHash string, fixupHash string) ([]todo.Todo, error) {
|
||||||
isOriginal := func(t todo.Todo) bool {
|
isOriginal := func(t todo.Todo) bool {
|
||||||
return t.Command == todo.Pick && equalHash(t.Commit, originalHash)
|
return (t.Command == todo.Pick || t.Command == todo.Merge) && equalHash(t.Commit, originalHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
isFixup := func(t todo.Todo) bool {
|
isFixup := func(t todo.Todo) bool {
|
||||||
|
@ -284,7 +284,6 @@ func TestRebaseCommands_moveFixupCommitDown(t *testing.T) {
|
|||||||
expectedErr: nil,
|
expectedErr: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// TODO: is this something we actually want to support?
|
|
||||||
name: "fixup commit is separated from original commit",
|
name: "fixup commit is separated from original commit",
|
||||||
todos: []todo.Todo{
|
todos: []todo.Todo{
|
||||||
{Command: todo.Pick, Commit: "original"},
|
{Command: todo.Pick, Commit: "original"},
|
||||||
@ -300,6 +299,22 @@ func TestRebaseCommands_moveFixupCommitDown(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedErr: nil,
|
expectedErr: nil,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "fixup commit is separated from original merge commit",
|
||||||
|
todos: []todo.Todo{
|
||||||
|
{Command: todo.Merge, Commit: "original"},
|
||||||
|
{Command: todo.Pick, Commit: "other"},
|
||||||
|
{Command: todo.Pick, Commit: "fixup"},
|
||||||
|
},
|
||||||
|
originalHash: "original",
|
||||||
|
fixupHash: "fixup",
|
||||||
|
expectedTodos: []todo.Todo{
|
||||||
|
{Command: todo.Merge, Commit: "original"},
|
||||||
|
{Command: todo.Fixup, Commit: "fixup"},
|
||||||
|
{Command: todo.Pick, Commit: "other"},
|
||||||
|
},
|
||||||
|
expectedErr: nil,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "More original hashes than expected",
|
name: "More original hashes than expected",
|
||||||
todos: []todo.Todo{
|
todos: []todo.Todo{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user