diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-02-26 11:51:02 +0100 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2023-06-22 18:57:58 +0200 |
commit | 3928d0ebda6952975059405544183bb1e63c0e1f (patch) | |
tree | e9369348db9401c683142cad2b5a293e780260da /pkg/integration | |
parent | d66ca7751c22a888497d53830a4d94db02506def (diff) |
Insert fake todo entry for a conflicting commit that is being applied
When stopping in a rebase because of a conflict, it is nice to see the commit
that git is trying to apply. Create a fake todo entry labelled "conflict" for
this, and show the "<-- YOU ARE HERE ---" string for that one (in red) instead
of for the real current head.
Diffstat (limited to 'pkg/integration')
7 files changed, 64 insertions, 11 deletions
diff --git a/pkg/integration/tests/branch/rebase_and_drop.go b/pkg/integration/tests/branch/rebase_and_drop.go index 9c95e40e1..4c6712f23 100644 --- a/pkg/integration/tests/branch/rebase_and_drop.go +++ b/pkg/integration/tests/branch/rebase_and_drop.go @@ -53,7 +53,8 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{ TopLines( MatchesRegexp(`pick.*to keep`).IsSelected(), MatchesRegexp(`pick.*to remove`), - MatchesRegexp("YOU ARE HERE.*second-change-branch unrelated change"), + MatchesRegexp(`conflict.*YOU ARE HERE.*first change`), + MatchesRegexp("second-change-branch unrelated change"), MatchesRegexp("second change"), MatchesRegexp("original"), ). @@ -62,7 +63,8 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{ TopLines( MatchesRegexp(`pick.*to keep`), MatchesRegexp(`drop.*to remove`).IsSelected(), - MatchesRegexp("YOU ARE HERE.*second-change-branch unrelated change"), + MatchesRegexp(`conflict.*YOU ARE HERE.*first change`), + MatchesRegexp("second-change-branch unrelated change"), MatchesRegexp("second change"), MatchesRegexp("original"), ) diff --git a/pkg/integration/tests/interactive_rebase/amend_commit_with_conflict.go b/pkg/integration/tests/interactive_rebase/amend_commit_with_conflict.go index 0483487f3..2226b5196 100644 --- a/pkg/integration/tests/interactive_rebase/amend_commit_with_conflict.go +++ b/pkg/integration/tests/interactive_rebase/amend_commit_with_conflict.go @@ -35,8 +35,8 @@ var AmendCommitWithConflict = NewIntegrationTest(NewIntegrationTestArgs{ }). Lines( Contains("pick").Contains("three"), - // Would be nice to see "fixup! two" here, because that's what git is trying to apply right now - Contains("<-- YOU ARE HERE --- two"), + Contains("conflict").Contains("<-- YOU ARE HERE --- fixup! two"), + Contains("two"), Contains("one"), ) @@ -66,8 +66,8 @@ var AmendCommitWithConflict = NewIntegrationTest(NewIntegrationTestArgs{ t.Views().Commits(). Lines( - // Would be nice to see "three" here, because that's what git is trying to apply right now - Contains("<-- YOU ARE HERE --- two"), + Contains("<-- YOU ARE HERE --- three"), + Contains("two"), Contains("one"), ) }, diff --git a/pkg/integration/tests/interactive_rebase/edit_the_confl_commit.go b/pkg/integration/tests/interactive_rebase/edit_the_confl_commit.go new file mode 100644 index 000000000..96ec81c74 --- /dev/null +++ b/pkg/integration/tests/interactive_rebase/edit_the_confl_commit.go @@ -0,0 +1,47 @@ +package interactive_rebase + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var EditTheConflCommit = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Swap two commits, causing a conflict; then try to interact with the 'confl' commit, which results in an error.", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("myfile", "one") + shell.Commit("commit one") + shell.UpdateFileAndAdd("myfile", "two") + shell.Commit("commit two") + shell.UpdateFileAndAdd("myfile", "three") + shell.Commit("commit three") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Lines( + Contains("commit three").IsSelected(), + Contains("commit two"), + Contains("commit one"), + ). + Press(keys.Commits.MoveDownCommit). + Tap(func() { + t.Common().AcknowledgeConflicts() + }). + Focus(). + Lines( + Contains("pick").Contains("commit two"), + Contains("conflict").Contains("<-- YOU ARE HERE --- commit three"), + Contains("commit one"), + ). + NavigateToLine(Contains("<-- YOU ARE HERE --- commit three")). + Press(keys.Commits.RenameCommit) + + t.ExpectPopup().Alert(). + Title(Equals("Error")). + Content(Contains("Changing this kind of rebase todo entry is not allowed")). + Confirm() + }, +}) diff --git a/pkg/integration/tests/interactive_rebase/shared.go b/pkg/integration/tests/interactive_rebase/shared.go index 2d3746af4..2e42c7f76 100644 --- a/pkg/integration/tests/interactive_rebase/shared.go +++ b/pkg/integration/tests/interactive_rebase/shared.go @@ -10,8 +10,8 @@ func handleConflictsFromSwap(t *TestDriver) { t.Views().Commits(). Lines( Contains("pick").Contains("commit two"), - // Would be nice to see "three" here, it's the one that conflicted - Contains("<-- YOU ARE HERE --- commit one"), + Contains("conflict").Contains("<-- YOU ARE HERE --- commit three"), + Contains("commit one"), ) t.Views().Files(). diff --git a/pkg/integration/tests/sync/pull_rebase_interactive_conflict.go b/pkg/integration/tests/sync/pull_rebase_interactive_conflict.go index 896c5cc45..9e66f3bcd 100644 --- a/pkg/integration/tests/sync/pull_rebase_interactive_conflict.go +++ b/pkg/integration/tests/sync/pull_rebase_interactive_conflict.go @@ -47,7 +47,8 @@ var PullRebaseInteractiveConflict = NewIntegrationTest(NewIntegrationTestArgs{ t.Views().Commits(). Lines( Contains("pick").Contains("five"), - Contains("YOU ARE HERE").Contains("three"), + Contains("conflict").Contains("YOU ARE HERE").Contains("four"), + Contains("three"), Contains("two"), Contains("one"), ) diff --git a/pkg/integration/tests/sync/pull_rebase_interactive_conflict_drop.go b/pkg/integration/tests/sync/pull_rebase_interactive_conflict_drop.go index 1950571b3..9ca3a0ebe 100644 --- a/pkg/integration/tests/sync/pull_rebase_interactive_conflict_drop.go +++ b/pkg/integration/tests/sync/pull_rebase_interactive_conflict_drop.go @@ -48,14 +48,16 @@ var PullRebaseInteractiveConflictDrop = NewIntegrationTest(NewIntegrationTestArg Focus(). Lines( Contains("pick").Contains("five").IsSelected(), - Contains("YOU ARE HERE").Contains("three"), + Contains("conflict").Contains("YOU ARE HERE").Contains("four"), + Contains("three"), Contains("two"), Contains("one"), ). Press(keys.Universal.Remove). Lines( Contains("drop").Contains("five").IsSelected(), - Contains("YOU ARE HERE").Contains("three"), + Contains("conflict").Contains("YOU ARE HERE").Contains("four"), + Contains("three"), Contains("two"), Contains("one"), ) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index aa303a44c..02d4f8432 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -105,6 +105,7 @@ var tests = []*components.IntegrationTest{ interactive_rebase.DropTodoCommitWithUpdateRefShowBranchHeads, interactive_rebase.EditFirstCommit, interactive_rebase.EditNonTodoCommitDuringRebase, + interactive_rebase.EditTheConflCommit, interactive_rebase.FixupFirstCommit, interactive_rebase.FixupSecondCommit, interactive_rebase.Move, |