undo

package
v0.67.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UndoCheckoutAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Drop some commits and then undo/redo the actions",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("one")
		shell.EmptyCommit("two")
		shell.EmptyCommit("three")
		shell.EmptyCommit("four")

		shell.NewBranch("other_branch")
		shell.Checkout("master")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {

		confirmCommitDrop := func() {
			t.ExpectPopup().Confirmation().
				Title(Equals("Drop commit")).
				Content(Equals("Are you sure you want to drop the selected commit(s)?")).
				Confirm()
		}

		confirmUndoDrop := func() {
			t.ExpectPopup().Confirmation().
				Title(Equals("Undo")).
				Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
				Confirm()
		}

		confirmRedoDrop := func() {
			t.ExpectPopup().Confirmation().
				Title(Equals("Redo")).
				Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
				Confirm()
		}

		t.Views().Commits().Focus().
			Lines(
				Contains("four").IsSelected(),
				Contains("three"),
				Contains("two"),
				Contains("one"),
			).
			Press(keys.Universal.Remove).
			Tap(confirmCommitDrop).
			Lines(
				Contains("three").IsSelected(),
				Contains("two"),
				Contains("one"),
			)

		t.Views().Branches().Focus().
			Lines(
				Contains("master").IsSelected(),
				Contains("other_branch"),
			).
			SelectNextItem().
			PressPrimaryAction().
			Lines(
				Contains("other_branch").IsSelected(),
				Contains("master"),
			)

		t.Views().Commits().Focus().
			Lines(
				Contains("four").IsSelected(),
				Contains("three"),
				Contains("two"),
				Contains("one"),
			).
			Press(keys.Universal.Remove).
			Tap(confirmCommitDrop).
			Lines(
				Contains("three").IsSelected(),
				Contains("two"),
				Contains("one"),
			).
			Press(keys.Universal.Undo).
			Tap(confirmUndoDrop).
			Lines(
				Contains("four").IsSelected(),
				Contains("three"),
				Contains("two"),
				Contains("one"),
			).
			Press(keys.Universal.Undo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Undo")).
					Content(Contains("Are you sure you want to checkout 'master'?")).
					Confirm()

				t.Views().Branches().
					IsFocused().
					Lines(
						Contains("master").IsSelected(),
						Contains("other_branch"),
					)
			}).
			Focus().
			Lines(
				Contains("three").IsSelected(),
				Contains("two"),
				Contains("one"),
			).
			Press(keys.Universal.Undo).
			Tap(confirmUndoDrop).
			Lines(
				Contains("four").IsSelected(),
				Contains("three"),
				Contains("two"),
				Contains("one"),
			).
			Press(keys.Universal.Redo).
			Tap(confirmRedoDrop).
			Lines(
				Contains("three").IsSelected(),
				Contains("two"),
				Contains("one"),
			).
			Press(keys.Universal.Redo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Redo")).
					Content(Contains("Are you sure you want to checkout 'other_branch'?")).
					Confirm()

				t.Views().Branches().
					IsFocused().
					Lines(
						Contains("other_branch").IsSelected(),
						Contains("master"),
					)
			}).
			Focus().
			Press(keys.Universal.Redo).
			Tap(confirmRedoDrop).
			Lines(
				Contains("three").IsSelected(),
				Contains("two"),
				Contains("one"),
			)
	},
})
View Source
var UndoCherryPick = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Undo/redo a cherry-pick",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("base")
		shell.NewBranch("feature")
		shell.CreateFileAndAdd("feature-file", "feature content")
		shell.Commit("feature commit")
		shell.Checkout("master")
		shell.CreateFileAndAdd("master-file", "master content")
		shell.Commit("master commit")
		shell.CherryPick("feature")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().Focus().
			Lines(
				Contains("feature commit").IsSelected(),
				Contains("master commit"),
				Contains("base"),
			).
			Press(keys.Universal.Undo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Undo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("master commit").IsSelected(),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()

		t.Views().Commits().
			Press(keys.Universal.Redo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Redo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("feature commit").IsSelected(),
				Contains("master commit"),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()
	},
})
View Source
var UndoCommit = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Undo/redo a commit",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateFileAndAdd("other-file", "other-file-1")
		shell.Commit("one")
		shell.CreateFileAndAdd("file", "file-1")
		shell.Commit("two")
		shell.UpdateFile("other-file", "other-file-2")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		confirmUndo := func() {
			t.ExpectPopup().Confirmation().
				Title(Equals("Undo")).
				Content(MatchesRegexp(`Are you sure you want to soft reset to '.*'\?`)).
				Confirm()
		}

		confirmRedo := func() {
			t.ExpectPopup().Confirmation().
				Title(Equals("Redo")).
				Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
				Confirm()
		}

		confirmDiscardFile := func() {
			t.ExpectPopup().Menu().
				Title(Equals("Discard changes")).
				Select(Contains("Discard all changes")).
				Confirm()
		}

		t.Views().Files().
			Lines(
				Contains(" M other-file"),
			)

		t.Views().Commits().Focus().
			Lines(
				Contains("two").IsSelected(),
				Contains("one"),
			).
			Press(keys.Universal.Undo).
			Tap(confirmUndo).
			Lines(
				Contains("one").IsSelected(),
			)

		t.Views().Files().
			Lines(
				Equals("▼ /"),
				Equals("  A  file"),
				Equals("   M other-file"),
			)

		t.Views().Commits().Focus().
			Press(keys.Universal.Redo).
			Tap(confirmRedo).
			Lines(
				Contains("two").IsSelected(),
				Contains("one"),
			)

		t.Views().Files().
			Lines(
				Equals(" M other-file"),
			)

		t.Views().Commits().Focus().
			Press(keys.Universal.Undo).
			Tap(confirmUndo).
			Lines(
				Contains("one").IsSelected(),
			)

		t.Views().Files().Focus().
			Lines(
				Equals("▼ /"),
				Equals("  A  file"),
				Equals("   M other-file").IsSelected(),
			).
			Press(keys.Universal.PrevItem).
			Press(keys.Universal.Remove).
			Tap(confirmDiscardFile).
			Lines(
				Equals(" M other-file"),
			).
			Press(keys.Universal.Redo).
			Tap(confirmRedo)

		t.Views().Commits().
			Lines(
				Contains("two"),
				Contains("one"),
			)

		t.Views().Files().
			Lines(
				Equals(" M other-file"),
			)
	},
})
View Source
var UndoConflictingCherryPick = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Undo/redo a cherry-pick that was committed after resolving conflicts",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateFileAndAdd("file", "base content")
		shell.Commit("base")
		shell.NewBranch("feature")
		shell.UpdateFileAndAdd("file", "feature content")
		shell.Commit("feature commit")
		shell.Checkout("master")
		shell.UpdateFileAndAdd("file", "master content")
		shell.Commit("master commit")
		shell.RunCommandExpectError([]string{"git", "cherry-pick", "feature"})
		shell.UpdateFileAndAdd("file", "resolved content")
		shell.ContinueCherryPick()
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().Focus().
			Lines(
				Contains("feature commit").IsSelected(),
				Contains("master commit"),
				Contains("base"),
			).
			Press(keys.Universal.Undo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Undo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("master commit").IsSelected(),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()

		t.Views().Commits().
			Press(keys.Universal.Redo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Redo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("feature commit").IsSelected(),
				Contains("master commit"),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()
	},
})
View Source
var UndoConflictingMerge = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Undo/redo a merge that was committed after resolving conflicts",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateFileAndAdd("file", "base content")
		shell.Commit("base")
		shell.NewBranch("feature")
		shell.UpdateFileAndAdd("file", "feature content")
		shell.Commit("feature commit")
		shell.Checkout("master")
		shell.UpdateFileAndAdd("file", "master content")
		shell.Commit("master commit")
		shell.RunCommandExpectError([]string{"git", "merge", "--no-ff", "feature"})
		shell.UpdateFileAndAdd("file", "resolved content")
		shell.ContinueMerge()
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().Focus().
			Lines(
				Contains("Merge branch 'feature'").IsSelected(),
				Contains("feature commit"),
				Contains("master commit"),
				Contains("base"),
			).
			Press(keys.Universal.Undo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Undo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("master commit").IsSelected(),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()

		t.Views().Commits().
			Press(keys.Universal.Redo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Redo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("Merge branch 'feature'").IsSelected(),
				Contains("feature commit"),
				Contains("master commit"),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()
	},
})
View Source
var UndoConflictingRebase = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Undo/redo a rebase that was continued after resolving conflicts",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateFileAndAdd("file", "base content")
		shell.Commit("base")
		shell.NewBranch("topic")
		shell.UpdateFileAndAdd("file", "topic content")
		shell.Commit("topic commit 1")
		shell.CreateFileAndAdd("other-file", "content")
		shell.Commit("topic commit 2")
		shell.Checkout("master")
		shell.UpdateFileAndAdd("file", "master content")
		shell.Commit("master commit")
		shell.Checkout("topic")
		shell.RunCommandExpectError([]string{"git", "rebase", "master"})
		shell.UpdateFileAndAdd("file", "resolved content")
		shell.ContinueRebase()
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().Focus().
			Lines(
				Contains("topic commit 2").IsSelected(),
				Contains("topic commit 1"),
				Contains("master commit"),
				Contains("base"),
			).
			Press(keys.Universal.Undo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Undo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("topic commit 2").IsSelected(),
				Contains("topic commit 1"),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()

		t.Views().Commits().
			Press(keys.Universal.Redo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Redo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("topic commit 2").IsSelected(),
				Contains("topic commit 1"),
				Contains("master commit"),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()
	},
})
View Source
var UndoDrop = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Drop some commits and then undo/redo the actions",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("one")
		shell.EmptyCommit("two")
		shell.EmptyCommit("three")
		shell.EmptyCommit("four")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		confirmCommitDrop := func() {
			t.ExpectPopup().Confirmation().
				Title(Equals("Drop commit")).
				Content(Equals("Are you sure you want to drop the selected commit(s)?")).
				Confirm()
		}

		confirmUndo := func() {
			t.ExpectPopup().Confirmation().
				Title(Equals("Undo")).
				Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
				Confirm()
		}

		confirmRedo := func() {
			t.ExpectPopup().Confirmation().
				Title(Equals("Redo")).
				Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
				Confirm()
		}

		t.Views().Commits().Focus().
			Lines(
				Contains("four").IsSelected(),
				Contains("three"),
				Contains("two"),
				Contains("one"),
			).
			Press(keys.Universal.Remove).
			Tap(confirmCommitDrop).
			Lines(
				Contains("three").IsSelected(),
				Contains("two"),
				Contains("one"),
			).
			Press(keys.Universal.Remove).
			Tap(confirmCommitDrop).
			Lines(
				Contains("two").IsSelected(),
				Contains("one"),
			).
			Press(keys.Universal.Undo).
			Tap(confirmUndo).
			Lines(
				Contains("three").IsSelected(),
				Contains("two"),
				Contains("one"),
			).
			Press(keys.Universal.Undo).
			Tap(confirmUndo).
			Lines(
				Contains("four").IsSelected(),
				Contains("three"),
				Contains("two"),
				Contains("one"),
			).
			Press(keys.Universal.Redo).
			Tap(confirmRedo).
			Lines(
				Contains("three").IsSelected(),
				Contains("two"),
				Contains("one"),
			).
			Press(keys.Universal.Redo).
			Tap(confirmRedo).
			Lines(
				Contains("two").IsSelected(),
				Contains("one"),
			)
	},
})
View Source
var UndoMerge = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Undo/redo a merge",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("base")
		shell.NewBranch("feature")
		shell.CreateFileAndAdd("feature-file", "feature content")
		shell.Commit("feature commit")
		shell.Checkout("master")
		shell.CreateFileAndAdd("master-file", "master content")
		shell.Commit("master commit")
		shell.Merge("feature")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().Focus().
			Lines(
				Contains("Merge branch 'feature'").IsSelected(),
				Contains("feature commit"),
				Contains("master commit"),
				Contains("base"),
			).
			Press(keys.Universal.Undo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Undo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("master commit").IsSelected(),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()

		t.Views().Commits().
			Press(keys.Universal.Redo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Redo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("Merge branch 'feature'").IsSelected(),
				Contains("feature commit"),
				Contains("master commit"),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()
	},
})
View Source
var UndoPull = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Undo/redo a pull",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("base")
		shell.CreateFileAndAdd("file", "content")
		shell.Commit("pulled commit")
		shell.CloneIntoRemote("origin")
		shell.SetBranchUpstream("master", "origin/master")
		shell.HardReset("HEAD^")
		shell.Pull()
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().Focus().
			Lines(
				Contains("pulled commit").IsSelected(),
				Contains("base"),
			).
			Press(keys.Universal.Undo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Undo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("base").IsSelected(),
			)

		t.Views().Files().
			IsEmpty()

		t.Views().Commits().
			Press(keys.Universal.Redo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Redo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("pulled commit").IsSelected(),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()
	},
})
View Source
var UndoPullWithConflictingRebase = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Undo/redo a pull whose rebase was continued after resolving conflicts",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateFileAndAdd("file", "base content")
		shell.Commit("base")
		shell.UpdateFileAndAdd("file", "remote content")
		shell.Commit("remote commit")
		shell.CloneIntoRemote("origin")
		shell.SetBranchUpstream("master", "origin/master")
		shell.HardReset("HEAD^")
		shell.UpdateFileAndAdd("file", "local content")
		shell.Commit("local commit 1")
		shell.CreateFileAndAdd("other-file", "content")
		shell.Commit("local commit 2")
		shell.SetConfig("pull.rebase", "true")
		shell.RunCommandExpectError([]string{"git", "pull", "--no-edit"})
		shell.UpdateFileAndAdd("file", "resolved content")
		shell.ContinueRebase()
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().Focus().
			Lines(
				Contains("local commit 2").IsSelected(),
				Contains("local commit 1"),
				Contains("remote commit"),
				Contains("base"),
			).
			Press(keys.Universal.Undo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Undo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("local commit 2").IsSelected(),
				Contains("local commit 1"),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()

		t.Views().Commits().
			Press(keys.Universal.Redo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Redo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("local commit 2").IsSelected(),
				Contains("local commit 1"),
				Contains("remote commit"),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()
	},
})
View Source
var UndoPullWithRebase = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Undo/redo a pull that rebases the local commits",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("base")
		shell.CreateFileAndAdd("remote-file", "content")
		shell.Commit("remote commit")
		shell.CloneIntoRemote("origin")
		shell.SetBranchUpstream("master", "origin/master")
		shell.HardReset("HEAD^")
		shell.CreateFileAndAdd("local-file-1", "content")
		shell.Commit("local commit 1")
		shell.CreateFileAndAdd("local-file-2", "content")
		shell.Commit("local commit 2")
		shell.SetConfig("pull.rebase", "true")
		shell.Pull()
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().Focus().
			Lines(
				Contains("local commit 2").IsSelected(),
				Contains("local commit 1"),
				Contains("remote commit"),
				Contains("base"),
			).
			Press(keys.Universal.Undo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Undo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("local commit 2").IsSelected(),
				Contains("local commit 1"),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()

		t.Views().Commits().
			Press(keys.Universal.Redo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Redo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("local commit 2").IsSelected(),
				Contains("local commit 1"),
				Contains("remote commit"),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()
	},
})
View Source
var UndoReset = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Undo/redo a hard reset",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("base")
		shell.CreateFileAndAdd("file", "content")
		shell.Commit("commit to reset away")
		shell.HardReset("HEAD^")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().Focus().
			Lines(
				Contains("base").IsSelected(),
			).
			Press(keys.Universal.Undo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Undo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("commit to reset away").IsSelected(),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()

		t.Views().Commits().
			Press(keys.Universal.Redo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Redo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("base").IsSelected(),
			)

		t.Views().Files().
			IsEmpty()
	},
})
View Source
var UndoRevert = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Undo/redo a revert",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("base")
		shell.CreateFileAndAdd("file", "content")
		shell.Commit("commit to revert")
		shell.Revert("HEAD")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().Focus().
			Lines(
				Contains(`Revert "commit to revert"`).IsSelected(),
				Contains("commit to revert"),
				Contains("base"),
			).
			Press(keys.Universal.Undo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Undo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains("commit to revert").IsSelected(),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()

		t.Views().Commits().
			Press(keys.Universal.Redo).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Redo")).
					Content(MatchesRegexp(`Are you sure you want to hard reset to '.*'\? An auto-stash will be performed if necessary\.`)).
					Confirm()
			}).
			Lines(
				Contains(`Revert "commit to revert"`).IsSelected(),
				Contains("commit to revert"),
				Contains("base"),
			)

		t.Views().Files().
			IsEmpty()
	},
})

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL