diff

package
v0.0.0-...-8fc5405 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Diff = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "View the diff of two branches, then view the reverse diff",
	ExtraCmdArgs: "",
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.NewBranch("branch-a")
		shell.CreateFileAndAdd("file1", "first line")
		shell.Commit("first commit")

		shell.NewBranch("branch-b")
		shell.UpdateFileAndAdd("file1", "first line\nsecond line")
		shell.Commit("update")

		shell.Checkout("branch-a")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			TopLines(
				Contains("branch-a"),
				Contains("branch-b"),
			).
			Press(keys.Universal.DiffingMenu)

		t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(Contains(`diff branch-a`)).Confirm()

		t.Views().Branches().
			IsFocused().
			Tap(func() {
				t.Views().Information().Content(Contains("showing output for: git diff branch-a branch-a"))
			}).
			SelectNextItem().
			Tap(func() {
				t.Views().Information().Content(Contains("showing output for: git diff branch-a branch-b"))
				t.Views().Main().Content(Contains("+second line"))
			}).
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			SelectedLine(Contains("update")).
			Tap(func() {
				t.Views().Main().Content(Contains("+second line"))
			}).
			PressEnter()

		t.Views().CommitFiles().
			IsFocused().
			SelectedLine(Contains("file1")).
			Tap(func() {
				t.Views().Main().Content(Contains("+second line"))
			}).
			PressEscape()

		t.Views().SubCommits().PressEscape()

		t.Views().Branches().
			IsFocused().
			Press(keys.Universal.DiffingMenu)

		t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm()
		t.Views().Information().Content(Contains("showing output for: git diff branch-a branch-b -R"))
		t.Views().Main().Content(Contains("-second line"))
	},
})
View Source
var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Create a patch from the diff between two branches and apply the patch.",
	ExtraCmdArgs: "",
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.NewBranch("branch-a")
		shell.CreateFileAndAdd("file1", "first line\n")
		shell.Commit("first commit")

		shell.NewBranch("branch-b")
		shell.UpdateFileAndAdd("file1", "first line\nsecond line\n")
		shell.Commit("update")

		shell.Checkout("branch-a")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("branch-a"),
				Contains("branch-b"),
			).
			Press(keys.Universal.DiffingMenu)

		t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(Equals("diff branch-a")).Confirm()

		t.Views().Information().Content(Contains("showing output for: git diff branch-a branch-a"))

		t.Views().Branches().
			IsFocused().
			SelectNextItem().
			Tap(func() {
				t.Views().Information().Content(Contains("showing output for: git diff branch-a branch-b"))
				t.Views().Main().Content(Contains("+second line"))
			}).
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			SelectedLine(Contains("update")).
			Tap(func() {
				t.Views().Main().Content(Contains("+second line"))
			}).
			PressEnter()

		t.Views().CommitFiles().
			IsFocused().
			SelectedLine(Contains("file1")).
			Tap(func() {
				t.Views().Main().Content(Contains("+second line"))
			}).
			PressPrimaryAction().
			Press(keys.Universal.DiffingMenu).
			Tap(func() {
				t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(Contains("exit diff mode")).Confirm()

				t.Views().Information().Content(DoesNotContain("building patch"))
			}).
			Press(keys.Universal.CreatePatchOptionsMenu)

		t.ExpectPopup().Menu().Title(Equals("Patch Options")).Select(MatchesRegexp("apply patch$")).Confirm()

		t.Views().Files().
			Focus().
			SelectedLine(Contains("file1"))

		t.Views().Main().Content(Contains("+second line"))
	},
})
View Source
var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "View the diff between two commits",
	ExtraCmdArgs: "",
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateFileAndAdd("file1", "first line\n")
		shell.Commit("first commit")
		shell.UpdateFileAndAdd("file1", "first line\nsecond line\n")
		shell.Commit("second commit")
		shell.UpdateFileAndAdd("file1", "first line\nsecond line\nthird line\n")
		shell.Commit("third commit")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			Lines(
				Contains("third commit").IsSelected(),
				Contains("second commit"),
				Contains("first commit"),
			).
			Press(keys.Universal.DiffingMenu).
			Tap(func() {
				t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(MatchesRegexp(`diff \w+`)).Confirm()

				t.Views().Information().Content(Contains("showing output for: git diff"))
			}).
			SelectNextItem().
			SelectNextItem().
			SelectedLine(Contains("first commit")).
			Tap(func() {
				t.Views().Main().Content(Contains("-second line\n-third line"))
			}).
			Press(keys.Universal.DiffingMenu).
			Tap(func() {
				t.ExpectPopup().Menu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm()

				t.Views().Main().Content(Contains("+second line\n+third line"))
			}).
			PressEnter()

		t.Views().CommitFiles().
			IsFocused().
			SelectedLine(Contains("file1"))

		t.Views().Main().Content(Contains("+second line\n+third line"))
	},
})
View Source
var IgnoreWhitespace = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "View diff with and without ignoring whitespace",
	ExtraCmdArgs: "",
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.CreateFileAndAdd("file1", "first line\nsecond line\n")
		shell.Commit("first commit")

		shell.UpdateFileAndAdd("file1", "first line changed\n  second line\n")
		shell.Commit("second commit")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			Tap(func() {

				t.Views().Main().Content(Contains("-first line\n-second line\n+first line changed\n+  second line\n"))
			}).
			Press(keys.Universal.ToggleWhitespaceInDiffView).
			Tap(func() {

				t.Views().Main().Content(Contains("-first line\n+first line changed\n"))
			})
	},
})

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