-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show confirmation menu when trying to amend changes while there are c…
…onflicts
- Loading branch information
1 parent
3722824
commit c4ee0c8
Showing
8 changed files
with
269 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
pkg/integration/tests/commit/amend_when_there_are_conflicts_and_amend.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package commit | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
var AmendWhenThereAreConflictsAndAmend = NewIntegrationTest(NewIntegrationTestArgs{ | ||
Description: "Amends the last commit from the files panel while a rebase is stopped due to conflicts, and amends the commit", | ||
ExtraCmdArgs: []string{}, | ||
Skip: false, | ||
SetupConfig: func(config *config.AppConfig) {}, | ||
SetupRepo: func(shell *Shell) { | ||
setupForAmendTests(shell) | ||
}, | ||
Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
doTheRebaseForAmendTests(t, keys) | ||
|
||
t.Views().Files(). | ||
Press(keys.Commits.AmendToCommit) | ||
|
||
t.ExpectPopup().Menu(). | ||
Title(Equals("Amend commit")). | ||
Select(Equals("Yes, amend previous commit")). | ||
Confirm() | ||
|
||
t.Views().Files().IsEmpty() | ||
|
||
t.Views().Commits(). | ||
Focus(). | ||
Lines( | ||
Contains("pick").Contains("commit three"), | ||
Contains("conflict").Contains("<-- YOU ARE HERE --- file1 changed in branch"), | ||
Contains("commit two"), | ||
Contains("file1 changed in master"), | ||
Contains("base commit"), | ||
) | ||
|
||
checkCommitContainsChange(t, "commit two", "+branch") | ||
}, | ||
}) |
43 changes: 43 additions & 0 deletions
43
pkg/integration/tests/commit/amend_when_there_are_conflicts_and_cancel.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package commit | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
var AmendWhenThereAreConflictsAndCancel = NewIntegrationTest(NewIntegrationTestArgs{ | ||
Description: "Amends the last commit from the files panel while a rebase is stopped due to conflicts, and cancels the confirmation", | ||
ExtraCmdArgs: []string{}, | ||
Skip: false, | ||
SetupConfig: func(config *config.AppConfig) {}, | ||
SetupRepo: func(shell *Shell) { | ||
setupForAmendTests(shell) | ||
}, | ||
Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
doTheRebaseForAmendTests(t, keys) | ||
|
||
t.Views().Files(). | ||
Press(keys.Commits.AmendToCommit) | ||
|
||
t.ExpectPopup().Menu(). | ||
Title(Equals("Amend commit")). | ||
Select(Equals("Cancel")). | ||
Confirm() | ||
|
||
// Check that nothing happened: | ||
t.Views().Files(). | ||
Lines( | ||
Contains("M file1"), | ||
) | ||
|
||
t.Views().Commits(). | ||
Focus(). | ||
Lines( | ||
Contains("pick").Contains("commit three"), | ||
Contains("conflict").Contains("<-- YOU ARE HERE --- file1 changed in branch"), | ||
Contains("commit two"), | ||
Contains("file1 changed in master"), | ||
Contains("base commit"), | ||
) | ||
}, | ||
}) |
41 changes: 41 additions & 0 deletions
41
pkg/integration/tests/commit/amend_when_there_are_conflicts_and_continue.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package commit | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
var AmendWhenThereAreConflictsAndContinue = NewIntegrationTest(NewIntegrationTestArgs{ | ||
Description: "Amends the last commit from the files panel while a rebase is stopped due to conflicts, and continues the rebase", | ||
ExtraCmdArgs: []string{}, | ||
Skip: false, | ||
SetupConfig: func(config *config.AppConfig) {}, | ||
SetupRepo: func(shell *Shell) { | ||
setupForAmendTests(shell) | ||
}, | ||
Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
doTheRebaseForAmendTests(t, keys) | ||
|
||
t.Views().Files(). | ||
Press(keys.Commits.AmendToCommit) | ||
|
||
t.ExpectPopup().Menu(). | ||
Title(Equals("Amend commit")). | ||
Select(Equals("No, continue rebase")). | ||
Confirm() | ||
|
||
t.Views().Files().IsEmpty() | ||
|
||
t.Views().Commits(). | ||
Focus(). | ||
Lines( | ||
Contains("commit three"), | ||
Contains("file1 changed in branch"), | ||
Contains("commit two"), | ||
Contains("file1 changed in master"), | ||
Contains("base commit"), | ||
) | ||
|
||
checkCommitContainsChange(t, "file1 changed in branch", "+branch") | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package commit | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
func setupForAmendTests(shell *Shell) { | ||
shell.EmptyCommit("base commit") | ||
shell.NewBranch("branch") | ||
shell.Checkout("master") | ||
shell.CreateFileAndAdd("file1", "master") | ||
shell.Commit("file1 changed in master") | ||
shell.Checkout("branch") | ||
shell.UpdateFileAndAdd("file2", "two") | ||
shell.Commit("commit two") | ||
shell.CreateFileAndAdd("file1", "branch") | ||
shell.Commit("file1 changed in branch") | ||
shell.UpdateFileAndAdd("file3", "three") | ||
shell.Commit("commit three") | ||
} | ||
|
||
func doTheRebaseForAmendTests(t *TestDriver, keys config.KeybindingConfig) { | ||
t.Views().Commits(). | ||
Focus(). | ||
Lines( | ||
Contains("commit three").IsSelected(), | ||
Contains("file1 changed in branch"), | ||
Contains("commit two"), | ||
Contains("base commit"), | ||
) | ||
t.Views().Branches(). | ||
Focus(). | ||
NavigateToLine(Contains("master")). | ||
Press(keys.Branches.RebaseBranch). | ||
Tap(func() { | ||
t.ExpectPopup().Menu(). | ||
Title(Equals("Rebase 'branch'")). | ||
Select(Contains("Simple rebase")). | ||
Confirm() | ||
t.Common().AcknowledgeConflicts() | ||
}) | ||
|
||
t.Views().Commits(). | ||
Lines( | ||
Contains("pick").Contains("commit three"), | ||
Contains("conflict").Contains("<-- YOU ARE HERE --- file1 changed in branch"), | ||
Contains("commit two"), | ||
Contains("file1 changed in master"), | ||
Contains("base commit"), | ||
) | ||
|
||
t.Views().Files(). | ||
Focus(). | ||
PressEnter() | ||
|
||
t.Views().MergeConflicts(). | ||
IsFocused(). | ||
SelectNextItem(). // choose "incoming" | ||
PressPrimaryAction() | ||
|
||
t.ExpectPopup().Confirmation(). | ||
Title(Equals("Continue")). | ||
Content(Contains("All merge conflicts resolved. Continue?")). | ||
Cancel() | ||
} | ||
|
||
func checkCommitContainsChange(t *TestDriver, commitSubject string, change string) { | ||
t.Views().Commits(). | ||
Focus(). | ||
NavigateToLine(Contains(commitSubject)) | ||
t.Views().Main(). | ||
Content(Contains(change)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters