Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CopyToClipboard = NewIntegrationTest(NewIntegrationTestArgs{ Description: "The copy menu allows to copy name and diff of selected/all files", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) { config.GetUserConfig().OS.CopyToClipboardCmd = "printf '%s' {{text}} > clipboard" }, SetupRepo: func(shell *Shell) { shell.EmptyCommit("initial commit") shell.AddWorktree("HEAD", "../linked-worktree", "mybranch") shell.Chdir("../linked-worktree") shell.CreateDir("dir") shell.CreateFileAndAdd("dir/file1", "1st line\n") shell.Commit("1") shell.UpdateFileAndAdd("dir/file1", "1st line\n2nd line\n") shell.CreateFileAndAdd("dir/file2", "file2\n") shell.Commit("2") shell.UpdateFileAndAdd("dir/file1", "1st line\n2nd line\n3rd line\n") shell.Commit("3") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("3").IsSelected(), Contains("2"), Contains("1"), Contains("initial commit"), ). SelectNextItem(). PressEnter() t.Views().CommitFiles(). IsFocused(). Lines( Contains("dir").IsSelected(), Contains("file1"), Contains("file2"), ). NavigateToLine(Contains("file1")). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("File name")). Confirm(). Tap(func() { t.ExpectToast(Equals("File name copied to clipboard")) expectClipboard(t, Equals("file1")) }) }). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Relative path")). Confirm(). Tap(func() { t.ExpectToast(Equals("File path copied to clipboard")) expectClipboard(t, Equals("dir/file1")) }) }). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Absolute path")). Confirm(). Tap(func() { t.ExpectToast(Equals("File path copied to clipboard")) worktreeDir, _ := os.Getwd() expectClipboard(t, Equals(worktreeDir+"/dir/file1")) }) }). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Diff of selected file")). Confirm(). Tap(func() { t.ExpectToast(Equals("File diff copied to clipboard")) expectClipboard(t, Contains("diff --git a/dir/file1 b/dir/file1").Contains("+2nd line").DoesNotContain("+1st line"). DoesNotContain("diff --git a/dir/file2 b/dir/file2").DoesNotContain("+file2")) }) }). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Diff of all files")). Confirm(). Tap(func() { t.ExpectToast(Equals("All files diff copied to clipboard")) expectClipboard(t, Contains("diff --git a/dir/file1 b/dir/file1").Contains("+2nd line").DoesNotContain("+1st line"). Contains("diff --git a/dir/file2 b/dir/file2").Contains("+file2")) }) }). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Content of selected file")). Confirm(). Tap(func() { t.ExpectToast(Equals("File content copied to clipboard")) expectClipboard(t, Equals("1st line\n2nd line\n")) }) }) t.Views().Commits(). Focus(). Press(keys.Universal.RangeSelectDown). PressEnter() t.Views().CommitFiles(). IsFocused(). Lines( Contains("dir").IsSelected(), Contains("file1"), Contains("file2"), ). NavigateToLine(Contains("file1")). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Diff of selected file")). Confirm(). Tap(func() { t.ExpectToast(Equals("File diff copied to clipboard")) expectClipboard(t, Contains("diff --git a/dir/file1 b/dir/file1").Contains("+1st line").Contains("+2nd line")) }) }). Press(keys.Files.CopyFileInfoToClipboard). Tap(func() { t.ExpectPopup().Menu(). Title(Equals("Copy to clipboard")). Select(Contains("Content of selected file")). Confirm(). Tap(func() { t.ExpectToast(Equals("File content copied to clipboard")) expectClipboard(t, Equals("1st line\n2nd line\n")) }) }) }, })
View Source
var CycleDiffRenderers = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Cycle forwards and backwards through configured diff renderers", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(cfg *config.AppConfig) { cfg.GetUserConfig().Git.DiffRenderers = []config.DiffRendererConfig{ {Name: "custom name", Command: "cat"}, {Command: "cat -n"}, {Type: "rawGit", Args: []string{"--color-words"}}, {Type: "rawGit"}, } }, SetupRepo: func(shell *Shell) { shell.CreateNCommits(1) }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Press(keys.Universal.CycleDiffRenderers) t.ExpectToast(Equals("Diff renderer: cat (2 of 4)")) t.Views().Commits().Press(keys.Universal.CycleDiffRenderers) t.ExpectToast(Equals("Diff renderer: --color-words (3 of 4)")) t.Views().Commits().Press(keys.Universal.CycleDiffRenderers) t.ExpectToast(Equals("Diff renderer: (default) (4 of 4)")) t.Views().Commits().Press(keys.Universal.CycleDiffRenderers) t.ExpectToast(Equals("Diff renderer: custom name (1 of 4)")) t.Views().Commits().Press(keys.Universal.CycleDiffRenderersReverse) t.ExpectToast(Equals("Diff renderer: (default) (4 of 4)")) t.Views().Commits().Press(keys.Universal.CycleDiffRenderersReverse) t.ExpectToast(Equals("Diff renderer: --color-words (3 of 4)")) }, })
View Source
var Diff = NewIntegrationTest(NewIntegrationTestArgs{ Description: "View the diff of two branches, then view the reverse diff", ExtraCmdArgs: []string{}, 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 --stat -p branch-a branch-a")) }). SelectNextItem(). Tap(func() { t.Views().Information().Content(Contains("Showing output for: git diff --stat -p 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 --stat -p 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: []string{}, 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 --stat -p branch-a branch-a")) t.Views().Branches(). IsFocused(). SelectNextItem(). Tap(func() { t.Views().Information().Content(Contains("Showing output for: git diff --stat -p 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(Contains("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().Secondary().Content(Contains("+second line")) }, })
View Source
var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{ Description: "View the diff between two commits", ExtraCmdArgs: []string{}, 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 DiffNonStickyRange = NewIntegrationTest(NewIntegrationTestArgs{ Description: "View the combined diff of multiple commits using a range selection", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.EmptyCommit("initial commit") 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"), Contains("initial commit"), ). Press(keys.Universal.RangeSelectDown). Press(keys.Universal.RangeSelectDown). Tap(func() { t.Views().Main().Content(Contains("Showing diff for range "). Contains("+first line\n+second line\n+third line")) }). PressEnter() t.Views().CommitFiles(). IsFocused(). SelectedLine(Contains("file1")) t.Views().Main().Content(Contains("+first line\n+second line\n+third line")) }, })
View Source
var DiffRendererMetadata = NewIntegrationTest(NewIntegrationTestArgs{ Description: "A diff renderer is told that we understand the OSC 1717 metadata protocol, and the records it emits don't show up in the rendered diff", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(cfg *config.AppConfig) { cfg.GetUserConfig().Git.DiffRenderers = []config.DiffRendererConfig{ {Command: `printf '\033]1717;1\007'; ` + `printf 'OFFERED:%s\n' "$OSC1717"; ` + `while IFS= read -r line; do printf '\033]1717;1;c;1;;file1\007%s\n' "$line"; done`}, } }, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("file1", "one\ntwo\n") shell.Commit("one") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("one").IsSelected(), ) t.Views().Main(). Content(Contains("OFFERED:V1")). ContainsLines( Equals("diff --git a/file1 b/file1"), Contains("new file mode"), Contains("index "), Equals("--- /dev/null"), Equals("+++ b/file1"), Equals("@@ -0,0 +1,2 @@"), Equals("+one"), Equals("+two"), ) }, })
View Source
var IgnoreWhitespace = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Toggle whitespace in the diff", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("myfile", initialFileContent) shell.Commit("initial commit") shell.UpdateFile("myfile", updatedFileContent) }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Main().ContainsLines( Contains(`-first-line`), Contains(`-old-second-line`), Contains(`-third-line`), Contains(`+ first-line`), Contains(`+ new-second-line`), Contains(`+ third-line`), ) t.Views().Files(). IsFocused(). Press(keys.Universal.ToggleWhitespaceInDiffView) t.Views().Main().ContainsLines( Contains(` first-line`), Contains(`-old-second-line`), Contains(`+ new-second-line`), Contains(` third-line`), ) t.Views().Files(). IsFocused(). Press(keys.Universal.ToggleWhitespaceInDiffView) t.Views().Main().ContainsLines( Contains(`-first-line`), Contains(`-old-second-line`), Contains(`-third-line`), Contains(`+ first-line`), Contains(`+ new-second-line`), Contains(`+ third-line`), ) }, })
View Source
var RenameSimilarityThresholdChange = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Change the rename similarity threshold while in the commits panel", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("original", "one\ntwo\nthree\nfour\nfive\n") shell.Commit("add original") shell.DeleteFileAndAdd("original") shell.CreateFileAndAdd("renamed", "one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\n") shell.Commit("change name and contents") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits().Focus() t.Views().Main(). ContainsLines( Contains("2 files changed, 10 insertions(+), 5 deletions(-)"), ) t.Views().Commits(). Press(keys.Universal.DecreaseRenameSimilarityThreshold). Tap(func() { t.ExpectToast(Equals("Changed rename similarity threshold to 45%")) }) t.Views().Main(). ContainsLines( Contains("original => renamed"), Contains("1 file changed, 5 insertions(+)"), ) t.Views().Commits(). Press(keys.Universal.FocusMainView) t.Views().Main(). Press(keys.Universal.IncreaseRenameSimilarityThreshold). Tap(func() { t.ExpectToast(Equals("Changed rename similarity threshold to 50%")) }). ContainsLines( Contains("2 files changed, 10 insertions(+), 5 deletions(-)"), ) }, })
View Source
var RenderThroughAPipe = NewIntegrationTest(NewIntegrationTestArgs{ Description: "A stdin filter renders the diff when it is fed through a pipe rather than run in a pty", ExtraCmdArgs: []string{}, Skip: false, ExtraEnvVars: map[string]string{"LAZYGIT_RENDER_WITHOUT_PTY": "1"}, SetupConfig: func(cfg *config.AppConfig) { cfg.GetUserConfig().Git.DiffRenderers = []config.DiffRendererConfig{ {Command: `echo "rendered at {{width}} columns"; cat`}, } }, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("file1", "one\n") shell.Commit("one") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("one").IsSelected(), ) t.Views().Main(). Content(MatchesRegexp(`rendered at \d+ columns`)). ContainsLines( Equals("diff --git a/file1 b/file1"), Contains("new file mode"), Contains("index "), Equals("--- /dev/null"), Equals("+++ b/file1"), Equals("@@ -0,0 +1 @@"), Equals("+one"), ) }, })
View Source
var StatFollowsAScreenModeChange = NewIntegrationTest(NewIntegrationTestArgs{ Description: "A commit's diffstat is laid out again to the width the view has after a screen mode change narrows it", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(cfg *config.AppConfig) { cfg.GetUserConfig().Git.DiffRenderers = []config.DiffRendererConfig{ {Type: "rawGit"}, } }, SetupRepo: func(shell *Shell) { lines := make([]string, 200) for i := range lines { lines[i] = "line " + strconv.Itoa(i) } shell.CreateFileAndAdd("file1", strings.Join(lines, "\n")+"\n") shell.Commit("add file1") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("add file1").IsSelected(), ) t.Views().Main(). ContainsViewLines( Contains("file1 | 200"), Contains("1 file changed"), ) t.Views().Commits().Press(keys.Universal.NextScreenMode) t.Views().Main(). ContainsViewLines( Contains("file1 | 200"), Contains("1 file changed"), ) }, })
View Source
var StatUsesTheViewWidth = NewIntegrationTest(NewIntegrationTestArgs{ Description: "The diffstat of a commit is laid out to the width of the view showing it", ExtraCmdArgs: []string{}, Skip: false, SetupConfig: func(cfg *config.AppConfig) { cfg.GetUserConfig().Git.DiffRenderers = []config.DiffRendererConfig{ {Type: "rawGit"}, } }, SetupRepo: func(shell *Shell) { lines := make([]string, 200) for i := range lines { lines[i] = "line " + strconv.Itoa(i) } shell.CreateFileAndAdd("file1", strings.Join(lines, "\n")+"\n") shell.Commit("add file1") }, Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( Contains("add file1").IsSelected(), ) t.Views().Main(). Content(MatchesRegexp(`(?m)^ file1 \| 200 \+{80,}$`)) }, })
Functions ¶
This section is empty.
Types ¶
This section is empty.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.