2022-12-21 13:52:23 +02:00
|
|
|
package diff
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
|
|
)
|
|
|
|
|
|
|
|
var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
|
|
|
|
Description: "View the diff between two commits",
|
|
|
|
ExtraCmdArgs: "",
|
|
|
|
Skip: false,
|
|
|
|
SetupConfig: func(config *config.AppConfig) {},
|
|
|
|
SetupRepo: func(shell *Shell) {
|
|
|
|
shell.CreateFileAndAdd("file1", "first line\n")
|
|
|
|
shell.Commit("first commit")
|
|
|
|
shell.UpdateFileAndAdd("file1", "first line\nsecond line\n")
|
|
|
|
shell.Commit("second commit")
|
|
|
|
shell.UpdateFileAndAdd("file1", "first line\nsecond line\nthird line\n")
|
|
|
|
shell.Commit("third commit")
|
|
|
|
},
|
|
|
|
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
2022-12-26 07:49:54 +02:00
|
|
|
input.SwitchToCommitsView()
|
2022-12-21 13:52:23 +02:00
|
|
|
|
2022-12-27 06:07:11 +02:00
|
|
|
assert.Views().Current().Lines(
|
2022-12-25 02:38:00 +02:00
|
|
|
Contains("third commit"),
|
|
|
|
Contains("second commit"),
|
|
|
|
Contains("first commit"),
|
|
|
|
)
|
2022-12-21 13:52:23 +02:00
|
|
|
|
2022-12-24 08:48:57 +02:00
|
|
|
input.Press(keys.Universal.DiffingMenu)
|
2022-12-27 02:34:41 +02:00
|
|
|
input.Menu().Title(Equals("Diffing")).Select(MatchesRegexp(`diff \w+`)).Confirm()
|
2022-12-24 08:48:57 +02:00
|
|
|
|
2022-12-27 06:07:11 +02:00
|
|
|
assert.Views().ByName("information").Content(Contains("showing output for: git diff"))
|
2022-12-21 13:52:23 +02:00
|
|
|
|
|
|
|
input.NextItem()
|
|
|
|
input.NextItem()
|
2022-12-27 06:07:11 +02:00
|
|
|
assert.Views().Current().SelectedLine(Contains("first commit"))
|
2022-12-21 13:52:23 +02:00
|
|
|
|
2022-12-27 06:07:11 +02:00
|
|
|
assert.Views().Main().Content(Contains("-second line\n-third line"))
|
2022-12-21 13:52:23 +02:00
|
|
|
|
2022-12-24 08:48:57 +02:00
|
|
|
input.Press(keys.Universal.DiffingMenu)
|
2022-12-27 02:34:41 +02:00
|
|
|
input.Menu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm()
|
2022-12-21 13:52:23 +02:00
|
|
|
|
2022-12-27 06:07:11 +02:00
|
|
|
assert.Views().Main().Content(Contains("+second line\n+third line"))
|
2022-12-21 13:52:23 +02:00
|
|
|
|
|
|
|
input.Enter()
|
|
|
|
|
2022-12-27 06:07:11 +02:00
|
|
|
assert.Views().Current().Name("commitFiles").SelectedLine(Contains("file1"))
|
|
|
|
assert.Views().Main().Content(Contains("+second line\n+third line"))
|
2022-12-21 13:52:23 +02:00
|
|
|
},
|
|
|
|
})
|