branch

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckoutByName = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Try to checkout branch by name. Verify that it also works on the branch with the special name @.",
	ExtraCmdArgs: "",
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.
			CreateNCommits(3).
			NewBranch("@").
			Checkout("master").
			EmptyCommit("blah")
	},
	Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
		input.SwitchToBranchesWindow()
		assert.CurrentViewName("localBranches")

		assert.MatchSelectedLine(Contains("master"))
		input.NextItem()
		assert.MatchSelectedLine(Contains("@"))
		input.PressKeys(keys.Branches.CheckoutBranchByName)
		assert.InPrompt()
		assert.MatchCurrentViewTitle(Equals("Branch name:"))
		input.Type("new-branch")
		input.Confirm()
		assert.InAlert()
		assert.MatchCurrentViewContent(Equals("Branch not found. Create a new branch named new-branch?"))
		input.Confirm()

		assert.CurrentViewName("localBranches")
		assert.MatchSelectedLine(Contains("new-branch"))
	},
})
View Source
var Delete = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Try to delete the checked out branch first (to no avail), and then delete another branch.",
	ExtraCmdArgs: "",
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("blah").
			NewBranch("branch-one").
			NewBranch("branch-two")
	},
	Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
		input.SwitchToBranchesWindow()
		assert.CurrentViewName("localBranches")

		assert.MatchSelectedLine(Contains("branch-two"))
		input.PressKeys(keys.Universal.Remove)
		assert.InAlert()
		assert.MatchCurrentViewContent(Contains("You cannot delete the checked out branch!"))

		input.Confirm()

		input.NextItem()
		assert.MatchSelectedLine(Contains("branch-one"))
		input.PressKeys(keys.Universal.Remove)
		assert.InConfirm()
		assert.MatchCurrentViewContent(Contains("Are you sure you want to delete the branch 'branch-one'?"))
		input.Confirm()
		assert.CurrentViewName("localBranches")
		assert.MatchSelectedLine(Contains("master"))
		assert.MatchCurrentViewContent(NotContains("branch-one"))
	},
})
View Source
var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Rebase onto another branch, deal with the conflicts.",
	ExtraCmdArgs: "",
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shared.MergeConflictsSetup(shell)
	},
	Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
		input.SwitchToBranchesWindow()
		assert.CurrentViewName("localBranches")

		assert.MatchSelectedLine(Contains("first-change-branch"))
		input.NextItem()
		assert.MatchSelectedLine(Contains("second-change-branch"))
		input.PressKeys(keys.Branches.RebaseBranch)

		assert.InConfirm()
		assert.MatchCurrentViewContent(Contains("Are you sure you want to rebase 'first-change-branch' onto 'second-change-branch'?"))
		input.Confirm()

		assert.InConfirm()
		assert.MatchCurrentViewContent(Contains("Conflicts!"))
		input.Confirm()

		assert.CurrentViewName("files")
		assert.MatchSelectedLine(Contains("file"))

		input.PressKeys(keys.Universal.Confirm)

		assert.CurrentViewName("mergeConflicts")
		input.PrimaryAction()

		assert.MatchViewContent("information", Contains("rebasing"))
		assert.InConfirm()
		assert.MatchCurrentViewContent(Contains("all merge conflicts resolved. Continue?"))
		input.Confirm()
		assert.MatchViewContent("information", NotContains("rebasing"))

		assert.MatchViewContent("commits", Contains("second-change-branch unrelated change"))
	},
})
View Source
var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Rebase onto another branch, deal with the conflicts. Also mark a commit to be dropped before continuing.",
	ExtraCmdArgs: "",
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shared.MergeConflictsSetup(shell)

		shell.EmptyCommit("to remove")
		shell.EmptyCommit("to keep")
	},
	Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
		input.SwitchToBranchesWindow()
		assert.CurrentViewName("localBranches")

		assert.MatchSelectedLine(Contains("first-change-branch"))
		input.NextItem()
		assert.MatchSelectedLine(Contains("second-change-branch"))
		input.PressKeys(keys.Branches.RebaseBranch)

		assert.InConfirm()
		assert.MatchCurrentViewContent(Contains("Are you sure you want to rebase 'first-change-branch' onto 'second-change-branch'?"))
		input.Confirm()

		assert.MatchViewContent("information", Contains("rebasing"))

		assert.InConfirm()
		assert.MatchCurrentViewContent(Contains("Conflicts!"))
		input.Confirm()

		assert.CurrentViewName("files")
		assert.MatchSelectedLine(Contains("file"))

		input.SwitchToCommitsWindow()
		assert.MatchSelectedLine(Contains("pick"))
		input.NextItem()
		input.PressKeys(keys.Universal.Remove)
		assert.MatchSelectedLine(Contains("to remove"))
		assert.MatchSelectedLine(Contains("drop"))

		input.SwitchToFilesWindow()

		input.PressKeys(keys.Universal.Confirm)

		assert.CurrentViewName("mergeConflicts")
		input.PrimaryAction()

		assert.InConfirm()
		assert.MatchCurrentViewContent(Contains("all merge conflicts resolved. Continue?"))
		input.Confirm()

		assert.MatchViewContent("information", NotContains("rebasing"))

		assert.MatchViewContent("commits", Contains("second-change-branch unrelated change"))
		assert.MatchViewContent("commits", Contains("to keep"))
		assert.MatchViewContent("commits", NotContains("to remove"))
	},
})
View Source
var Suggestions = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Checking out a branch with name suggestions",
	ExtraCmdArgs: "",
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("my commit message").
			NewBranch("new-branch").
			NewBranch("new-branch-2").
			NewBranch("new-branch-3").
			NewBranch("branch-to-checkout").
			NewBranch("other-new-branch-2").
			NewBranch("other-new-branch-3")
	},
	Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
		input.SwitchToBranchesWindow()
		assert.CurrentViewName("localBranches")

		input.PressKeys(keys.Branches.CheckoutBranchByName)
		assert.CurrentViewName("confirmation")

		input.Type("branch-to")

		input.PressKeys(keys.Universal.TogglePanel)
		assert.CurrentViewName("suggestions")

		assert.MatchSelectedLine(Contains("branch-to-checkout"))
		input.Confirm()

		assert.CurrentBranchName("branch-to-checkout")
	},
})

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