1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00

merge master into refactor-better-encapsulation

This commit is contained in:
Jesse Duffield
2023-05-02 19:05:42 +10:00
parent 8d68ab41b6
commit 5dacbb6293
25 changed files with 792 additions and 287 deletions

View File

@@ -0,0 +1,50 @@
package interactive_rebase
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var AmendFixupCommit = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Amends a staged file to a fixup commit, and checks that other unrelated fixup commits are not auto-squashed.",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.
CreateNCommits(1).
CreateFileAndAdd("first-fixup-file", "").Commit("fixup! commit 01").
CreateNCommitsStartingAt(2, 2).
CreateFileAndAdd("unrelated-fixup-file", "fixup 03").Commit("fixup! commit 03").
CreateFileAndAdd("fixup-file", "fixup 01")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("fixup! commit 03"),
Contains("commit 03"),
Contains("commit 02"),
Contains("fixup! commit 01"),
Contains("commit 01"),
).
NavigateToLine(Contains("fixup! commit 01")).
Press(keys.Commits.AmendToCommit).
Tap(func() {
t.ExpectPopup().Confirmation().
Title(Equals("Amend Commit")).
Content(Contains("Are you sure you want to amend this commit with your staged files?")).
Confirm()
}).
Lines(
Contains("fixup! commit 03"),
Contains("commit 03"),
Contains("commit 02"),
Contains("fixup! commit 01").IsSelected(),
Contains("commit 01"),
)
t.Views().Main().
Content(Contains("fixup 01"))
},
})

View File

@@ -23,31 +23,22 @@ var DropTodoCommitWithUpdateRef = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Commits().
Focus().
Lines(
Contains("(*) commit 06").IsSelected(),
Contains("commit 06").IsSelected(),
Contains("commit 05"),
Contains("commit 04"),
Contains("(*) commit 03"),
Contains("commit 03"),
Contains("commit 02"),
Contains("commit 01"),
).
// Once "e" is fixed we can just hit "e", but for now we need to
// manually do a command-line rebase
// NavigateToLine(Contains("commit 01")).
// Press(keys.Universal.Edit).
Tap(func() {
t.GlobalPress(keys.Universal.ExecuteCustomCommand)
t.ExpectPopup().Prompt().
Title(Equals("Custom Command:")).
Type(`git -c core.editor="perl -i -lpe 'print \"break\" if $.==1'" rebase -i HEAD~5`).
Confirm()
}).
NavigateToLine(Contains("commit 01")).
Press(keys.Universal.Edit).
Focus().
Lines(
Contains("pick").Contains("(*) commit 06"),
Contains("pick").Contains("commit 06"),
Contains("pick").Contains("commit 05"),
Contains("pick").Contains("commit 04"),
Contains("update-ref").Contains("master"),
Contains("pick").Contains("(*) commit 03"),
Contains("pick").Contains("commit 03"),
Contains("pick").Contains("commit 02"),
Contains("<-- YOU ARE HERE --- commit 01"),
).
@@ -59,9 +50,9 @@ var DropTodoCommitWithUpdateRef = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Commits().
IsFocused().
Lines(
Contains("(*) commit 06"),
Contains("commit 06"),
Contains("commit 04"),
Contains("(*) commit 03"),
Contains("commit 03"),
Contains("commit 02"),
Contains("commit 01"),
)

View File

@@ -0,0 +1,62 @@
package interactive_rebase
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var DropTodoCommitWithUpdateRefShowBranchHeads = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Drops a commit during interactive rebase when there is an update-ref in the git-rebase-todo file (with experimentalShowBranchHeads on)",
ExtraCmdArgs: "",
Skip: false,
GitVersion: From("2.38.0"),
SetupConfig: func(config *config.AppConfig) {
config.UserConfig.Gui.ExperimentalShowBranchHeads = true
},
SetupRepo: func(shell *Shell) {
shell.
CreateNCommits(3).
NewBranch("mybranch").
CreateNCommitsStartingAt(3, 4)
shell.SetConfig("rebase.updateRefs", "true")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("(*) commit 06").IsSelected(),
Contains("commit 05"),
Contains("commit 04"),
Contains("(*) commit 03"),
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToLine(Contains("commit 01")).
Press(keys.Universal.Edit).
Focus().
Lines(
Contains("pick").Contains("(*) commit 06"),
Contains("pick").Contains("commit 05"),
Contains("pick").Contains("commit 04"),
Contains("update-ref").Contains("master"),
Contains("pick").Contains("(*) commit 03"),
Contains("pick").Contains("commit 02"),
Contains("<-- YOU ARE HERE --- commit 01"),
).
NavigateToLine(Contains("commit 05")).
Press(keys.Universal.Remove)
t.Common().ContinueRebase()
t.Views().Commits().
IsFocused().
Lines(
Contains("(*) commit 06"),
Contains("commit 04"),
Contains("(*) commit 03"),
Contains("commit 02"),
Contains("commit 01"),
)
},
})

View File

@@ -88,10 +88,12 @@ var tests = []*components.IntegrationTest{
filter_by_path.TypeFile,
interactive_rebase.AdvancedInteractiveRebase,
interactive_rebase.AmendFirstCommit,
interactive_rebase.AmendFixupCommit,
interactive_rebase.AmendHeadCommitDuringRebase,
interactive_rebase.AmendMerge,
interactive_rebase.AmendNonHeadCommitDuringRebase,
interactive_rebase.DropTodoCommitWithUpdateRef,
interactive_rebase.DropTodoCommitWithUpdateRefShowBranchHeads,
interactive_rebase.EditFirstCommit,
interactive_rebase.EditNonTodoCommitDuringRebase,
interactive_rebase.FixupFirstCommit,