reflog

package
v0.0.0-...-00ab8b8 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Checkout = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Checkout a reflog commit as a detached head",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("one")
		shell.EmptyCommit("two")
		shell.EmptyCommit("three")
		shell.HardReset("HEAD^^")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().ReflogCommits().
			Focus().
			Lines(
				Contains("reset: moving to HEAD^^").IsSelected(),
				Contains("commit: three"),
				Contains("commit: two"),
				Contains("commit (initial): one"),
			).
			SelectNextItem().
			PressPrimaryAction().
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Contains("Checkout commit")).
					Content(Contains("Are you sure you want to checkout this commit?")).
					Confirm()
			}).
			TopLines(
				Contains("checkout: moving from master to").IsSelected(),
				Contains("reset: moving to HEAD^^"),
			)

		t.Views().Branches().
			Lines(
				Contains("(HEAD detached at").IsSelected(),
				Contains("master"),
			)

		t.Views().Commits().
			Focus().
			Lines(
				Contains("three").IsSelected(),
				Contains("two"),
				Contains("one"),
			)
	},
})
View Source
var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Cherry pick a reflog commit",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("one")
		shell.EmptyCommit("two")
		shell.EmptyCommit("three")
		shell.HardReset("HEAD^^")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().ReflogCommits().
			Focus().
			Lines(
				Contains("reset: moving to HEAD^^").IsSelected(),
				Contains("commit: three"),
				Contains("commit: two"),
				Contains("commit (initial): one"),
			).
			SelectNextItem().
			Press(keys.Commits.CherryPickCopy)

		t.Views().Information().Content(Contains("1 commit copied"))

		t.Views().Commits().
			Focus().
			Lines(
				Contains("one").IsSelected(),
			).
			Press(keys.Commits.PasteCommits).
			Tap(func() {
				t.ExpectPopup().Alert().
					Title(Equals("Cherry-pick")).
					Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
					Confirm()
			}).
			Lines(
				Contains("three").IsSelected(),
				Contains("one"),
			)
	},
})
View Source
var DoNotShowBranchMarkersInReflogSubcommits = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Verify that no branch heads are shown in the subcommits view of a reflog entry",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.AppState.GitLogShowGraph = "never"
	},
	SetupRepo: func(shell *Shell) {
		shell.NewBranch("branch1")
		shell.EmptyCommit("one")
		shell.EmptyCommit("two")
		shell.NewBranch("branch2")
		shell.EmptyCommit("three")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {

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

		t.Views().Branches().
			Focus().
			NavigateToLine(Contains("branch1")).
			PressPrimaryAction().
			NavigateToLine(Contains("branch2")).
			PressEnter().
			Tap(func() {
				t.Views().SubCommits().
					IsFocused().
					Lines(
						Contains("CI three"),
						Contains("CI * two"),
						Contains("CI one"),
					).
					PressEscape()
			}).
			NavigateToLine(Contains("branch2")).
			PressPrimaryAction()

		t.Views().ReflogCommits().
			Focus().
			TopLines(
				Contains("checkout: moving from branch1 to branch2").IsSelected(),
			).
			PressEnter().
			Tap(func() {
				t.Views().SubCommits().
					IsFocused().
					Lines(
						Contains("CI three"),
						Contains("CI two"),
						Contains("CI one"),
					)
			})
	},
})
View Source
var Patch = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Build a patch from a reflog commit and apply it",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("one")
		shell.EmptyCommit("two")
		shell.CreateFileAndAdd("file1", "content1")
		shell.CreateFileAndAdd("file2", "content2")
		shell.Commit("three")
		shell.HardReset("HEAD^^")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().ReflogCommits().
			Focus().
			Lines(
				Contains("reset: moving to HEAD^^").IsSelected(),
				Contains("commit: three"),
				Contains("commit: two"),
				Contains("commit (initial): one"),
			).
			SelectNextItem().
			Lines(
				Contains("reset: moving to HEAD^^"),
				Contains("commit: three").IsSelected(),
				Contains("commit: two"),
				Contains("commit (initial): one"),
			).
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains("three").IsSelected(),
				Contains("two"),
				Contains("one"),
			).
			PressEnter()

		t.Views().CommitFiles().
			IsFocused().
			Lines(
				Contains("file1").IsSelected(),
				Contains("file2"),
			).
			PressPrimaryAction()

		t.Views().Information().Content(Contains("Building patch"))

		t.Views().
			CommitFiles().
			Press(keys.Universal.CreatePatchOptionsMenu)

		t.ExpectPopup().Menu().
			Title(Equals("Patch options")).
			Select(MatchesRegexp(`Apply patch$`)).Confirm()

		t.Views().Files().Lines(
			Contains("file1"),
		)
	},
})
View Source
var Reset = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Hard reset to a reflog commit",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("one")
		shell.EmptyCommit("two")
		shell.EmptyCommit("three")
		shell.HardReset("HEAD^^")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().ReflogCommits().
			Focus().
			Lines(
				Contains("reset: moving to HEAD^^").IsSelected(),
				Contains("commit: three"),
				Contains("commit: two"),
				Contains("commit (initial): one"),
			).
			SelectNextItem().
			Press(keys.Commits.ViewResetOptions).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Contains("Reset to")).
					Select(Contains("Hard reset")).
					Confirm()
			}).
			TopLines(
				Contains("reset: moving to").IsSelected(),
				Contains("reset: moving to HEAD^^"),
			)

		t.Views().Commits().
			Focus().
			Lines(
				Contains("three").IsSelected(),
				Contains("two"),
				Contains("one"),
			)
	},
})

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