cherry_pick

package
v0.66.4 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 3 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 AbortCherryPickAfterEditingPickedFile = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Abort a cherry-pick that stopped with conflicts after editing a file that it picked without conflicts",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.
			CreateFileAndAdd("conflicting-file", "original\n").
			CreateFileAndAdd("picked-file", "original\n").
			Commit("original").
			NewBranch("feature").
			UpdateFileAndAdd("conflicting-file", "feature\n").
			UpdateFileAndAdd("picked-file", "feature\n").
			Commit("feature change").
			Checkout("master").
			UpdateFileAndAdd("conflicting-file", "master\n").
			Commit("master change").
			RunCommandExpectError([]string{"git", "cherry-pick", "feature"}).
			UpdateFile("picked-file", "feature\nfix the build\n")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Status().Content(Equals("(cherry-picking) repo → master"))

		t.Views().Files().
			IsFocused().
			Lines(
				Equals("UU conflicting-file").IsSelected(),
			)

		t.GlobalPress(keys.Universal.CreateRebaseOptionsMenu)
		t.ExpectPopup().Menu().
			Title(Equals("Cherry-pick options")).
			Select(Contains("abort")).
			Confirm()

		t.ExpectPopup().Confirmation().
			Title(Equals("Abort the cherry-pick")).
			Content(Equals("Aborting the cherry-pick also discards the unstaged changes of these files. Are you sure?\n\n- picked-file")).
			Confirm()

		t.Views().Status().Content(Equals("repo → master"))

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

		t.Views().Commits().
			Lines(
				Contains("master change"),
				Contains("original"),
			)
	},
})
View Source
var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Cherry pick commits from the subcommits view, without conflicts",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
	},
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("base").
			NewBranch("first-branch").
			NewBranch("second-branch").
			Checkout("first-branch").
			EmptyCommit("one").
			EmptyCommit("two").
			Checkout("second-branch").
			EmptyCommit("three").
			EmptyCommit("four").
			Checkout("first-branch")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("first-branch"),
				Contains("second-branch"),
				Contains("master"),
			).
			SelectNextItem().
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains("four").IsSelected(),
				Contains("three"),
				Contains("base"),
			).
			Press(keys.Commits.CherryPickCopy).
			Tap(func() {
				t.Views().Information().Content(Contains("1 commit copied"))
			}).
			SelectNextItem().
			Press(keys.Commits.CherryPickCopy)

		t.Views().Information().Content(Contains("2 commits copied"))

		t.Views().Commits().
			Focus().
			Lines(
				Contains("two").IsSelected(),
				Contains("one"),
				Contains("base"),
			).
			Press(keys.Commits.PasteCommits).
			Tap(func() {

				t.Views().Information().Content(Contains("2 commits copied"))
			}).
			Tap(func() {
				t.ExpectPopup().Alert().
					Title(Equals("Cherry-pick")).
					Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")).
					Confirm()
			}).
			Tap(func() {
				t.Views().Information().Content(DoesNotContain("commits copied"))
			}).
			Lines(
				Contains("four"),
				Contains("three"),
				Contains("two").IsSelected(),
				Contains("one"),
				Contains("base"),
			)

		t.Views().Branches().
			Focus().
			NavigateToLine(Contains("master")).
			PressPrimaryAction()

		t.Views().Commits().
			Focus().
			Lines(
				Contains("base").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 2 copied commit(s) onto this branch?")).
					Confirm()
			}).
			Tap(func() {
				t.Views().Information().Content(DoesNotContain("commits copied"))
			}).
			Lines(
				Contains("four"),
				Contains("three"),
				Contains("base").IsSelected(),
			)
	},
})
View Source
var CherryPickAcrossWorktrees = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Copy commits in one worktree, drop them there, and paste them in another worktree",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("base").
			AddWorktree("master", "../linked-worktree", "newbranch").
			EmptyCommit("one").
			EmptyCommit("two")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			Lines(
				Contains("two").IsSelected(),
				Contains("one"),
				Contains("base"),
			).
			Press(keys.Universal.RangeSelectDown).
			Press(keys.Commits.CherryPickCopy).
			Tap(func() {
				t.Views().Information().Content(Contains("2 commits copied"))
			}).
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Drop commit")).
					Content(Contains("Are you sure you want to drop the selected commit(s)?")).
					Confirm()
			}).
			Lines(
				Contains("base").IsSelected(),
			)

		t.Views().Branches().
			Focus().
			NavigateToLine(Contains("newbranch")).
			Press(keys.Universal.Select).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Switch to worktree")).
					Content(Equals("This branch is checked out by worktree linked-worktree. Do you want to switch to that worktree?")).
					Confirm()
			}).
			Lines(
				Contains("newbranch").IsSelected(),
				Contains("master (worktree repo)"),
			)

		t.Views().Information().Content(Contains("2 commits copied"))

		t.Views().Commits().
			Focus().
			Lines(
				Contains("base").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 2 copied commit(s) onto this branch?")).
					Confirm()
			}).
			Lines(
				Contains("two"),
				Contains("one"),
				Contains("base").IsSelected(),
			)
	},
})
View Source
var CherryPickCommitThatBecomesEmpty = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Cherry-pick a commit that becomes empty at the destination",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("base").
			CreateFileAndAdd("file1", "change 1\n").
			CreateFileAndAdd("file2", "change 2\n").
			Commit("two changes in one commit").
			NewBranchFrom("branch", "HEAD^").
			CreateFileAndAdd("file1", "change 1\n").
			Commit("single change").
			CreateFileAndAdd("file3", "change 3\n").
			Commit("unrelated change").
			Checkout("master")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("master").IsSelected(),
				Contains("branch"),
			).
			SelectNextItem().
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains("unrelated change").IsSelected(),
				Contains("single change"),
				Contains("base"),
			).
			Press(keys.Universal.RangeSelectDown).
			Press(keys.Commits.CherryPickCopy).
			Tap(func() {
				t.Views().Information().Content(Contains("2 commits copied"))
			})

		t.Views().Commits().
			Focus().
			Lines(
				Contains("two changes in one commit").IsSelected(),
				Contains("base"),
			).
			Press(keys.Commits.PasteCommits).
			Tap(func() {
				t.ExpectPopup().Alert().
					Title(Equals("Cherry-pick")).
					Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")).
					Confirm()
			})

		if t.Git().Version().IsAtLeast(2, 45, 0) {
			t.Views().Commits().
				Lines(
					Contains("unrelated change"),
					Contains("single change"),
					Contains("two changes in one commit").IsSelected(),
					Contains("base"),
				).
				SelectPreviousItem()

			t.Views().Main().Content(DoesNotContain("diff --git"))
		} else {

			t.Views().Commits().
				Lines(
					Contains("unrelated change"),
					Contains("two changes in one commit").IsSelected(),
					Contains("base"),
				)
		}
	},
})
View Source
var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Cherry pick commits from the subcommits view, with conflicts",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
	},
	SetupRepo: func(shell *Shell) {
		shared.MergeConflictsSetup(shell)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("first-change-branch"),
				Contains("second-change-branch"),
				Contains("original-branch"),
			).
			SelectNextItem().
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			TopLines(
				Contains("second-change-branch unrelated change"),
				Contains("second change"),
			).
			Press(keys.Commits.CherryPickCopy).
			Tap(func() {
				t.Views().Information().Content(Contains("1 commit copied"))
			}).
			SelectNextItem().
			Press(keys.Commits.CherryPickCopy)

		t.Views().Information().Content(Contains("2 commits copied"))

		t.Views().Commits().
			Focus().
			TopLines(
				Contains("first change").IsSelected(),
			).
			Press(keys.Commits.PasteCommits)

		t.ExpectPopup().Alert().
			Title(Equals("Cherry-pick")).
			Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")).
			Confirm()

		t.Common().AcknowledgeConflicts()

		t.Views().Information().Content(Contains("2 commits copied"))

		t.Views().Files().
			IsFocused().
			SelectedLine(Contains("file")).
			PressEnter()

		t.Views().MergeConflicts().
			IsFocused().
			SelectNextItem().
			PressPrimaryAction()

		t.Common().ContinueOnConflictsResolved("cherry-pick")

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

		t.Views().Commits().
			Focus().
			TopLines(
				Contains("second-change-branch unrelated change"),
				Contains("second change").IsSelected(),
				Contains("first change"),
			).
			Tap(func() {

				t.Views().Main().
					Content(Contains("-First Change")).
					Content(Contains("+Second Change"))

				t.Views().Information().Content(Contains("2 commits copied"))
			}).
			PressEscape().
			Tap(func() {
				t.Views().Information().Content(DoesNotContain("commits copied"))
			})
	},
})
View Source
var CherryPickConflictsCommittedByUser = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Cherry pick two commits, the first of which conflicts; the user commits the resolution themselves before continuing",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
	},
	SetupRepo: func(shell *Shell) {
		shared.MergeConflictsSetup(shell)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("first-change-branch"),
				Contains("second-change-branch"),
				Contains("original-branch"),
			).
			SelectNextItem().
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			TopLines(
				Contains("second-change-branch unrelated change"),
				Contains("second change"),
			).
			Press(keys.Commits.CherryPickCopy).
			SelectNextItem().
			Press(keys.Commits.CherryPickCopy)

		t.Views().Information().Content(Contains("2 commits copied"))

		t.Views().Commits().
			Focus().
			TopLines(
				Contains("first change").IsSelected(),
			).
			Press(keys.Commits.PasteCommits)

		t.ExpectPopup().Alert().
			Title(Equals("Cherry-pick")).
			Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")).
			Confirm()

		t.Common().AcknowledgeConflicts()

		t.Shell().
			UpdateFileAndAdd("file", shared.SecondChangeFileContent).
			RunCommand([]string{"git", "commit", "--no-edit"})

		t.GlobalPress(keys.Universal.Refresh)

		t.Views().Status().Content(Equals("(cherry-picking) repo → first-change-branch"))

		t.Views().Commits().
			TopLines(
				Contains("─── Pending cherry-picks"),
				Contains("pick").DoesNotContain("CONFLICT").Contains("second-change-branch unrelated change"),
				Contains("─── Commits"),
				Contains("second change"),
				Contains("first change"),
			)

		t.Common().ContinueOnConflictsResolved("cherry-pick")

		t.Views().Status().Content(Equals("repo → first-change-branch"))

		t.Views().Commits().
			TopLines(
				Contains("second-change-branch unrelated change"),
				Contains("second change"),
				Contains("first change"),
			)
	},
})
View Source
var CherryPickConflictsEmptyCommitAfterResolving = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Cherry pick commits with conflicts, resolve them so that the commit becomes empty",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
	},
	SetupRepo: func(shell *Shell) {
		shared.MergeConflictsSetup(shell)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("first-change-branch"),
				Contains("second-change-branch"),
				Contains("original-branch"),
			).
			SelectNextItem().
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			TopLines(
				Contains("second-change-branch unrelated change"),
				Contains("second change"),
			).
			Press(keys.Universal.RangeSelectDown).
			Press(keys.Commits.CherryPickCopy)

		t.Views().Information().Content(Contains("2 commits copied"))

		t.Views().Commits().
			Focus().
			TopLines(
				Contains("first change").IsSelected(),
			).
			Press(keys.Commits.PasteCommits)

		t.ExpectPopup().Alert().
			Title(Equals("Cherry-pick")).
			Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")).
			Confirm()

		t.Common().AcknowledgeConflicts()

		t.Views().Files().
			IsFocused().
			SelectedLine(Contains("file")).
			Press(keys.Universal.Remove)

		t.ExpectPopup().Menu().
			Title(Equals("Discard changes")).
			Select(Contains("Discard all changes")).
			Confirm()

		t.Common().ContinueOnConflictsResolved("cherry-pick")

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

		t.Views().Commits().
			Focus().
			TopLines(
				Contains("second-change-branch unrelated change"),
				Contains("first change").IsSelected(),
				Contains("original"),
			)
	},
})
View Source
var CherryPickDuringRebase = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Cherry pick commits from the subcommits view during a rebase",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Git.Log.ShowGraph = "never"
		config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
	},
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("base").
			NewBranch("first-branch").
			NewBranch("second-branch").
			Checkout("first-branch").
			EmptyCommit("one").
			EmptyCommit("two").
			Checkout("second-branch").
			EmptyCommit("three").
			EmptyCommit("four").
			Checkout("first-branch")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("first-branch"),
				Contains("second-branch"),
				Contains("master"),
			).
			SelectNextItem().
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains("four").IsSelected(),
				Contains("three"),
				Contains("base"),
			).
			SelectNextItem().
			Press(keys.Commits.CherryPickCopy)

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

		t.Views().Commits().
			Focus().
			Lines(
				Contains("CI two").IsSelected(),
				Contains("CI one"),
				Contains("CI base"),
			).
			SelectNextItem().
			Press(keys.Universal.Edit).
			Lines(
				Contains("─── Pending rebase todos"),
				Contains("pick CI two"),
				Contains("─── Commits"),
				Contains("     CI one").IsSelected(),
				Contains("     CI base"),
			).
			Press(keys.Commits.PasteCommits).
			Tap(func() {
				t.ExpectPopup().Alert().
					Title(Equals("Cherry-pick")).
					Content(Contains("Are you sure you want to cherry-pick the 1 copied commit(s) onto this branch?")).
					Confirm()
			}).
			Tap(func() {
				t.Views().Information().Content(DoesNotContain("commit copied"))
			}).
			Lines(
				Contains("─── Pending rebase todos"),
				Contains("pick CI two"),
				Contains("─── Commits"),
				Contains("     CI three"),
				Contains("     CI one").IsSelected(),
				Contains("     CI base"),
			).
			Tap(func() {
				t.Common().ContinueRebase()
			}).
			Lines(
				Contains("CI two"),
				Contains("CI three"),
				Contains("CI one").IsSelected(),
				Contains("CI base"),
			)
	},
})
View Source
var CherryPickMerge = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Cherry pick a merge commit",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
	},
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("base").
			NewBranch("first-branch").
			NewBranch("second-branch").
			CreateFileAndAdd("file1.txt", "content").
			Commit("one").
			CreateFileAndAdd("file2.txt", "content").
			Commit("two").
			Checkout("master").
			Merge("second-branch").
			Checkout("first-branch")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("first-branch"),
				Contains("master"),
				Contains("second-branch"),
			).
			SelectNextItem().
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains("◎─╮ Merge branch 'second-branch'").IsSelected(),
				Contains("│ ○ two"),
				Contains("│ ○ one"),
				Contains("○ ╯ base"),
			).
			Press(keys.Commits.CherryPickCopy)

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

		t.Views().Commits().
			Focus().
			Lines(
				Contains("base").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 1 copied commit(s) onto this branch?")).
					Confirm()
			}).
			Tap(func() {
				t.Views().Information().Content(DoesNotContain("commit copied"))
			}).
			Lines(
				Contains("Merge branch 'second-branch'"),
				Contains("base").IsSelected(),
			).
			SelectPreviousItem()

		t.Views().Main().ContainsLines(
			Contains("Merge branch 'second-branch'"),
			Contains("---"),
			Contains("file1.txt | 1 +"),
			Contains("file2.txt | 1 +"),
			Contains("2 files changed, 2 insertions(+)"),
		)
	},
})
View Source
var CherryPickRange = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Cherry pick range of commits from the subcommits view, without conflicts",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
	},
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("base").
			NewBranch("first-branch").
			NewBranch("second-branch").
			Checkout("first-branch").
			EmptyCommit("one").
			EmptyCommit("two").
			Checkout("second-branch").
			EmptyCommit("three").
			EmptyCommit("four").
			Checkout("first-branch")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("first-branch"),
				Contains("second-branch"),
				Contains("master"),
			).
			SelectNextItem().
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains("four").IsSelected(),
				Contains("three"),
				Contains("base"),
			).
			Press(keys.Universal.RangeSelectDown).
			Lines(
				Contains("four").IsSelected(),
				Contains("three").IsSelected(),
				Contains("base"),
			).
			Press(keys.Commits.CherryPickCopy)

		t.Views().Information().Content(Contains("2 commits copied"))

		t.Views().Commits().
			Focus().
			Lines(
				Contains("two").IsSelected(),
				Contains("one"),
				Contains("base"),
			).
			Press(keys.Commits.PasteCommits).
			Tap(func() {
				t.ExpectPopup().Alert().
					Title(Equals("Cherry-pick")).
					Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")).
					Confirm()
			}).
			Tap(func() {
				t.Views().Information().Content(DoesNotContain("commits copied"))
			}).
			Lines(
				Contains("four"),
				Contains("three"),
				Contains("two").IsSelected(),
				Contains("one"),
				Contains("base"),
			)
	},
})
View Source
var CherryPickRangeAfterPaste = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Regression test: range-copy multiple commits after a previous paste",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
	},
	SetupRepo: func(shell *Shell) {
		shell.
			EmptyCommit("base").
			NewBranch("target").
			NewBranch("source").
			EmptyCommit("one").
			EmptyCommit("two").
			EmptyCommit("three").
			EmptyCommit("four").
			EmptyCommit("five").
			Checkout("target")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("target").IsSelected(),
				Contains("source"),
				Contains("master"),
			).
			SelectNextItem().
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains("five").IsSelected(),
				Contains("four"),
				Contains("three"),
				Contains("two"),
				Contains("one"),
				Contains("base"),
			).
			Press(keys.Commits.CherryPickCopy)

		t.Views().Commits().
			Focus().
			Lines(
				Contains("base").IsSelected(),
			).
			Press(keys.Commits.PasteCommits).
			Tap(func() {
				t.ExpectPopup().Alert().
					Title(Equals("Cherry-pick")).
					Content(Equals("Are you sure you want to cherry-pick the 1 copied commit(s) onto this branch?")).
					Confirm()
			}).
			Lines(
				Contains("five"),
				Contains("base").IsSelected(),
			).
			Tap(func() {

				t.Views().Information().Content(DoesNotContain("commits copied"))
			})

		t.Views().Branches().
			Focus().
			NavigateToLine(Contains("source")).
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			NavigateToLine(Contains("four")).
			Press(keys.Universal.RangeSelectDown).
			Press(keys.Universal.RangeSelectDown).
			Press(keys.Commits.CherryPickCopy).
			Tap(func() {
				t.Views().Information().Content(Contains("3 commits copied"))
			})

		t.Views().Commits().
			Focus().
			NavigateToLine(Contains("base")).
			Press(keys.Commits.PasteCommits).
			Tap(func() {
				t.ExpectPopup().Alert().
					Title(Equals("Cherry-pick")).
					Content(Equals("Are you sure you want to cherry-pick the 3 copied commit(s) onto this branch?")).
					Confirm()
			})

		t.Views().Commits().Lines(
			Contains("four"),
			Contains("three"),
			Contains("two"),
			Contains("five"),
			Contains("base").IsSelected(),
		)
	},
})
View Source
var CherryPickStoppedByUntrackedFile = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Cherry pick two commits; an untracked file stops the second one before git starts to apply it; continue after removing the file",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
	},
	SetupRepo: func(shell *Shell) {
		shell.
			CreateFileAndAdd("file", "original\n").
			Commit("base").
			NewBranch("source").
			CreateFileAndAdd("file1", "one\n").
			Commit("one").
			CreateFileAndAdd("file2", "two\n").
			Commit("two").
			Checkout("master").
			CreateFile("file2", "untracked\n")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("master"),
				Contains("source"),
			).
			SelectNextItem().
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains("two").IsSelected(),
				Contains("one"),
				Contains("base"),
			).
			Press(keys.Commits.CherryPickCopy).
			SelectNextItem().
			Press(keys.Commits.CherryPickCopy)

		t.Views().Information().Content(Contains("2 commits copied"))

		t.Views().Commits().
			Focus().
			Lines(
				Contains("base").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 2 copied commit(s) onto this branch?")).
					Confirm()
			}).
			Tap(func() {
				t.ExpectPopup().Alert().
					Title(Equals("Error")).
					Content(Contains("The following untracked working tree files would be overwritten by merge")).
					Confirm()
			}).
			Lines(
				Contains("─── Pending cherry-picks"),
				Contains("pick").DoesNotContain("CONFLICT").Contains("two"),
				Contains("─── Commits"),
				Contains("one"),
				Contains("base"),
			)

		t.Views().Status().
			Content(Equals("(cherry-picking) repo → master"))

		t.Shell().DeleteFile("file2")

		t.GlobalPress(keys.Universal.CreateRebaseOptionsMenu)
		t.ExpectPopup().Menu().
			Title(Equals("Cherry-pick options")).
			Select(Contains("continue")).
			Confirm()

		t.Views().Status().Content(Equals("repo → master"))

		t.Views().Commits().
			Lines(
				Contains("two"),
				Contains("one"),
				Contains("base"),
			)
	},
})
View Source
var LockErrorPartwayThroughCherryPick = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Cherry pick two commits while another git process takes index.lock partway through",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
	},
	SetupRepo: func(shell *Shell) {
		shell.
			CreateFileAndAdd("file", "original\n").
			Commit("base").
			NewBranch("source").
			CreateFileAndAdd("file1", "one\n").
			Commit("one").
			CreateFileAndAdd("file2", "two\n").
			Commit("two").
			Checkout("master")

		shared.HoldIndexLockAfterNextCommit(shell)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Branches().
			Focus().
			Lines(
				Contains("master"),
				Contains("source"),
			).
			SelectNextItem().
			PressEnter()

		t.Views().SubCommits().
			IsFocused().
			Lines(
				Contains("two").IsSelected(),
				Contains("one"),
				Contains("base"),
			).
			Press(keys.Commits.CherryPickCopy).
			SelectNextItem().
			Press(keys.Commits.CherryPickCopy)

		t.Views().Information().Content(Contains("2 commits copied"))

		t.Views().Commits().
			Focus().
			Lines(
				Contains("base").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 2 copied commit(s) onto this branch?")).
					Confirm()
			}).
			Lines(
				Contains("two"),
				Contains("one"),
				Contains("base"),
			)
	},
})

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