submodule

package
v0.65.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 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 Add = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Add a submodule",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.Clone("other_repo")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Submodules().Focus().
			Press(keys.Universal.New).
			Tap(func() {
				t.ExpectPopup().Prompt().
					Title(Equals("New submodule URL:")).
					Type("../other_repo").Confirm()

				t.ExpectPopup().Prompt().
					Title(Equals("New submodule name:")).
					InitialText(Equals("other_repo")).
					Clear().Type("my_submodule").Confirm()

				t.ExpectPopup().Prompt().
					Title(Equals("New submodule path:")).
					InitialText(Equals("my_submodule")).
					Clear().Type("my_submodule_path").Confirm()
			}).
			Lines(
				Contains("my_submodule").IsSelected(),
			)

		t.Views().Main().TopLines(
			Contains("Name: my_submodule"),
			Contains("Path: my_submodule_path"),
			Contains("Url:  ../other_repo"),
		)

		t.Views().Files().Focus().
			Lines(
				Equals("▼ /").IsSelected(),
				Equals("  A  .gitmodules"),
				Equals("  A  my_submodule_path (submodule)"),
			).
			SelectNextItem().
			Tap(func() {
				t.Views().Main().Content(
					Contains("[submodule \"my_submodule\"]").
						Contains("path = my_submodule_path").
						Contains("url = ../other_repo"),
				)
			}).
			SelectNextItem().
			Tap(func() {
				t.Views().Main().Content(
					Contains("Submodule my_submodule_path").
						Contains("(new submodule)"),
				)
			})
	},
})
View Source
var Enter = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Enter a submodule, add a commit, and then stage the change in the parent repo",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     config.Keybinding{"e"},
				Context: "files",
				Command: "git commit --allow-empty -m \"empty commit\"",
			},
		}
	},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.CloneIntoSubmodule("my_submodule_name", "my_submodule_path")
		shell.GitAddAll()
		shell.Commit("add submodule")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		assertInParentRepo := func() {
			t.Views().Status().Content(Contains("repo"))
		}
		assertInSubmodule := func() {
			t.Views().Status().Content(Contains("my_submodule_path"))
		}

		assertInParentRepo()

		t.Views().Submodules().Focus().
			Lines(
				Contains("my_submodule_name").IsSelected(),
			).
			PressEnter()

		assertInSubmodule()

		t.Views().Files().IsFocused().
			Press(config.Keybinding{"e"}).
			Tap(func() {
				t.Views().Commits().Content(Contains("empty commit"))
			}).
			PressEscape()

		assertInParentRepo()

		t.Views().Submodules().IsFocused()

		t.Views().Main().Content(Contains("> empty commit"))

		t.Views().Files().Focus().
			Lines(
				MatchesRegexp(` M.*my_submodule_path \(submodule\)`).IsSelected(),
			).
			Tap(func() {

				t.Views().Main().Content(Contains("> empty commit"))
			}).
			PressPrimaryAction().
			Press(keys.Files.CommitChanges).
			Tap(func() {
				t.ExpectPopup().CommitMessagePanel().Type("submodule change").Confirm()
			}).
			IsEmpty()

		t.Views().Submodules().Focus()

		t.Views().Main().Content(DoesNotContain("> empty commit"))
	},
})
View Source
var EnterFromDotfileBareRepo = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Enter a submodule of a dotfile bare repo and escape back out again",
	ExtraCmdArgs: []string{"--git-dir={{.actualPath}}/.bare", "--work-tree={{.actualPath}}/repo"},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {

		shell.EmptyCommit("initial submodule commit")
		shell.Clone("my_submodule_name")

		shell.DeleteFile(".git")
		shell.RunCommand([]string{"git", "init", "--bare", "../.bare"})
		gitInBareRepo := []string{"git", "--git-dir=../.bare", "--work-tree=."}
		shell.RunCommand(append(gitInBareRepo, "checkout", "-b", "mybranch"))
		shell.CreateFile("blah", "blah\n")
		shell.RunCommand(append(gitInBareRepo, "add", "blah"))
		shell.RunCommand(append(gitInBareRepo, "commit", "-m", "initial commit"))
		shell.RunCommand(append(gitInBareRepo, "-c", "protocol.file.allow=always", "submodule",
			"add", "--name", "my_submodule_name", "../my_submodule_name", "my_submodule_path"))
		shell.RunCommand(append(gitInBareRepo, "commit", "-m", "add submodule"))
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		assertInParentRepo := func() {
			t.Views().Status().Content(Contains("repo"))
			t.Views().Commits().Lines(
				Contains("add submodule"),
				Contains("initial commit"),
			)
		}

		assertInParentRepo()

		t.Views().Submodules().Focus().
			Lines(
				Contains("my_submodule_name").IsSelected(),
			).
			PressEnter()

		t.Views().Status().Content(Contains("my_submodule_path"))
		t.Views().Commits().Lines(
			Contains("initial submodule commit"),
		)

		t.Views().Files().IsFocused().PressEscape()

		assertInParentRepo()
		t.Views().Submodules().IsFocused()
	},
})
View Source
var EnterNested = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Enter a nested submodule",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(cfg *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		setupNestedSubmodules(shell)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Submodules().Focus().
			Lines(
				Equals("outerSubName").IsSelected(),
				Equals("  - innerSubName"),
			).
			Tap(func() {
				t.Views().Main().ContainsLines(
					Contains("Name: outerSubName"),
					Contains("Path: modules/outerSubPath"),
					Contains("Url:  ../outerSubmodule"),
				)
			}).
			SelectNextItem().
			Tap(func() {
				t.Views().Main().ContainsLines(
					Contains("Name: outerSubName/innerSubName"),
					Contains("Path: modules/outerSubPath/modules/innerSubPath"),
					Contains("Url:  ../innerSubmodule"),
				)
			}).
			PressEnter()

		t.Views().Status().Content(Contains("innerSubPath"))
		t.Views().Commits().ContainsLines(
			Contains("initial inner commit"),
		)

		t.Views().Files().PressEscape()
		t.Views().Status().Content(Contains("repo"))
	},
})
View Source
var Remove = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Remove a submodule",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.CloneIntoSubmodule("my_submodule_name", "my_submodule_path")
		shell.GitAddAll()
		shell.Commit("add submodule")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		gitDirSubmodulePath := ".git/modules/my_submodule_name"
		t.FileSystem().PathPresent(gitDirSubmodulePath)

		t.Views().Submodules().Focus().
			Lines(
				Contains("my_submodule_name").IsSelected(),
			).
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Remove submodule")).
					Content(Equals("Are you sure you want to remove submodule 'my_submodule_name' and its corresponding directory? This is irreversible.")).
					Confirm()
			}).
			IsEmpty()

		t.Views().Files().Focus().
			Lines(
				Equals("▼ /").IsSelected(),
				Equals("  M  .gitmodules"),
				Equals("  D  my_submodule_path"),
			).
			SelectNextItem()

		t.Views().Main().Content(
			Contains("-[submodule \"my_submodule_name\"]").
				Contains("-   path = my_submodule_path").
				Contains("-   url = ../my_submodule_name"),
		)

		t.FileSystem().PathNotPresent(gitDirSubmodulePath)
	},
})
View Source
var RemoveNested = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Remove a nested submodule",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		setupNestedSubmodules(shell)
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		gitDirSubmodulePath, _ := filepath.Abs(".git/modules/outerSubName/modules/innerSubName")
		t.FileSystem().PathPresent(gitDirSubmodulePath)

		t.Views().Submodules().Focus().
			Lines(
				Equals("outerSubName").IsSelected(),
				Equals("  - innerSubName"),
			).
			SelectNextItem().
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectPopup().Confirmation().
					Title(Equals("Remove submodule")).
					Content(Equals("Are you sure you want to remove submodule 'outerSubName/innerSubName' and its corresponding directory? This is irreversible.")).
					Confirm()
			}).
			Lines(
				Equals("outerSubName").IsSelected(),
			).
			Press(keys.Universal.GoInto)

		t.Views().Files().IsFocused().
			Lines(
				Equals("▼ /").IsSelected(),
				Equals("  M  .gitmodules"),
				Equals("  ▼ modules"),
				Equals("    D  innerSubPath"),
			).
			NavigateToLine(Contains(".gitmodules"))

		t.Views().Main().Content(
			Contains("-[submodule \"innerSubName\"]").
				Contains("-   path = modules/innerSubPath").
				Contains("-   url = ../innerSubmodule"),
		)

		t.FileSystem().PathNotPresent(gitDirSubmodulePath)
	},
})
View Source
var Reset = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Enter a submodule, create a commit and stage some changes, then reset the submodule from back in the parent repo. This test captures functionality around getting a dirty submodule out of your files panel.",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
			{
				Key:     config.Keybinding{"e"},
				Context: "files",
				Command: "git commit --allow-empty -m \"empty commit\" && echo \"my_file content\" > my_file",
			},
		}
	},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.CloneIntoSubmodule("my_submodule_name", "my_submodule_path")
		shell.GitAddAll()
		shell.Commit("add submodule")

		shell.CreateFile("other_file", "")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		assertInParentRepo := func() {
			t.Views().Status().Content(Contains("repo"))
		}
		assertInSubmodule := func() {
			t.Views().Status().Content(Contains("my_submodule_path"))
		}

		assertInParentRepo()

		t.Views().Submodules().Focus().
			Lines(
				Contains("my_submodule_name").IsSelected(),
			).
			PressEnter()

		assertInSubmodule()

		t.Views().Files().IsFocused().
			Press(config.Keybinding{"e"}).
			Tap(func() {
				t.Views().Commits().Content(Contains("empty commit"))
				t.Views().Files().Content(Contains("my_file"))
			}).
			Lines(
				Contains("my_file").IsSelected(),
			).
			PressPrimaryAction().
			PressEscape()

		assertInParentRepo()

		t.Views().Submodules().IsFocused()

		t.Views().Main().Content(Contains("Submodule my_submodule_path contains modified content"))

		t.Views().Files().Focus().
			Lines(
				Equals("▼ /"),
				Equals("   M my_submodule_path (submodule)"),
				Equals("  ?? other_file").IsSelected(),
			).
			Press(keys.Universal.ToggleRangeSelect).
			SelectPreviousItem().
			Lines(
				Equals("▼ /"),
				Equals("   M my_submodule_path (submodule)").IsSelected(),
				Equals("  ?? other_file").IsSelected(),
			).
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectToast(Contains("Disabled: Multiselection not supported for submodules"))
			}).
			Press(keys.Universal.ToggleRangeSelect).
			Lines(
				Equals("▼ /"),
				Equals("   M my_submodule_path (submodule)").IsSelected(),
				Equals("  ?? other_file"),
			).
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("my_submodule_path")).
					Select(Contains("Stash uncommitted submodule changes and update")).
					Confirm()
			}).
			Lines(
				Equals("?? other_file").IsSelected(),
			)

		t.Views().Submodules().Focus().
			PressEnter()

		assertInSubmodule()

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

		t.Views().Commits().Lines(
			Contains("first commit").IsSelected(),
		)

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

		t.Views().Stash().Focus().
			Lines(
				Contains("WIP on master").IsSelected(),
			)

		t.Views().Main().Content(Contains("my_file content"))
	},
})
View Source
var ResetFolder = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Reset submodule changes located in a nested folder.",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(cfg *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.CreateDir("dir")
		shell.CloneIntoSubmodule("submodule1", "dir/submodule1")
		shell.CloneIntoSubmodule("submodule2", "dir/submodule2")
		shell.GitAddAll()
		shell.Commit("add submodules")

		shell.CreateFile("dir/submodule1/file", "")
		shell.CreateFile("dir/submodule2/file", "")
		shell.CreateFile("dir/file", "")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().Focus().
			Lines(
				Equals("▼ dir").IsSelected(),
				Equals("  ?? file"),
				Equals("   M submodule1 (submodule)"),
				Equals("   M submodule2 (submodule)"),
			).
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectToast(Contains("Disabled: Multiselection not supported for submodules"))
			}).
			SelectNextItem().
			Press(keys.Universal.ToggleRangeSelect).
			SelectNextItem().
			Lines(
				Equals("▼ dir"),
				Equals("  ?? file").IsSelected(),
				Equals("   M submodule1 (submodule)").IsSelected(),
				Equals("   M submodule2 (submodule)"),
			).
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectToast(Contains("Disabled: Multiselection not supported for submodules"))
			}).
			Press(keys.Universal.ToggleRangeSelect).
			Press(keys.Universal.ToggleRangeSelect).
			SelectNextItem().
			Lines(
				Equals("▼ dir"),
				Equals("  ?? file"),
				Equals("   M submodule1 (submodule)").IsSelected(),
				Equals("   M submodule2 (submodule)").IsSelected(),
			).
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectToast(Contains("Disabled: Multiselection not supported for submodules"))
			}).
			Press(keys.Universal.ToggleRangeSelect).
			NavigateToLine(Contains("file")).
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Discard changes")).
					Select(Contains("Discard all changes")).
					Confirm()
			}).
			NavigateToLine(Contains("▼ dir")).
			Lines(
				Equals("▼ dir").IsSelected(),
				Equals("   M submodule1 (submodule)"),
				Equals("   M submodule2 (submodule)"),
			).
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectToast(Contains("Disabled: Multiselection not supported for submodules"))
			}).
			SelectNextItem().
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("dir/submodule1")).
					Select(Contains("Stash uncommitted submodule changes and update")).
					Confirm()
			}).
			NavigateToLine(Contains("▼ dir")).
			Lines(
				Equals("▼ dir").IsSelected(),
				Equals("   M submodule2 (submodule)"),
			).
			Press(keys.Universal.ToggleRangeSelect).
			SelectNextItem().
			Lines(
				Equals("▼ dir").IsSelected(),
				Equals("   M submodule2 (submodule)").IsSelected(),
			).
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("dir/submodule2")).
					Select(Contains("Stash uncommitted submodule changes and update")).
					Cancel()
			}).
			NavigateToLine(Contains("▼ dir")).
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("dir/submodule2")).
					Select(Contains("Stash uncommitted submodule changes and update")).
					Confirm()
			}).
			IsEmpty()
	},
})
View Source
var ResolveConflict = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Resolve a submodule conflict (both sides moved the gitlink) by picking one side's commit",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Gui.ShowFileTree = false
	},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.CloneIntoSubmodule("my_submodule_name", "my_submodule_path")
		shell.GitAddAll()
		shell.Commit("add submodule")

		sub := "my_submodule_path"

		shell.RunCommand([]string{"git", "-C", sub, "checkout", "-b", "left"})
		shell.RunCommand([]string{"git", "-C", sub, "commit", "--allow-empty", "-m", "left"})
		shell.RunCommand([]string{"git", "-C", sub, "checkout", "-b", "right", "HEAD~1"})
		shell.RunCommand([]string{"git", "-C", sub, "commit", "--allow-empty", "-m", "right"})

		shell.RunCommand([]string{"git", "checkout", "-b", "ours"})
		shell.RunCommand([]string{"git", "-C", sub, "checkout", "left"})
		shell.RunCommand([]string{"git", "add", sub})
		shell.Commit("ours")

		shell.RunCommand([]string{"git", "checkout", "-b", "theirs", "HEAD~1"})
		shell.RunCommand([]string{"git", "-C", sub, "checkout", "right"})
		shell.RunCommand([]string{"git", "add", sub})
		shell.Commit("theirs")

		shell.RunCommand([]string{"git", "checkout", "ours"})
		shell.RunCommand([]string{"git", "-C", sub, "checkout", "left"})
		shell.RunCommandExpectError([]string{"git", "merge", "theirs"})
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().
			Focus().
			Lines(
				Contains("UU my_submodule_path (submodule)").IsSelected(),
			).
			Tap(func() {

				t.Views().Main().Content(
					Contains("Conflict: the submodule").
						Contains("Current changes:").Contains("left").
						Contains("Incoming changes:").Contains("right"),
				)
			}).
			Press(keys.Universal.GoInto).
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Merge conflicts")).
					Select(Contains("Take current commit").Contains("left")).
					Select(Contains("Take incoming commit").Contains("right")).
					Cancel()
			}).
			PressPrimaryAction().
			Tap(func() {
				t.ExpectPopup().Menu().
					Title(Equals("Merge conflicts")).
					Select(Contains("Take incoming commit")).
					Confirm()
			}).
			Lines(
				Contains("M  my_submodule_path (submodule)").IsSelected(),
			)
	},
})
View Source
var ResolveConflictRewoundSide = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "When a side of a submodule conflict added no commits of its own (it was rewound), the main view shows the commit it points at instead of an empty log",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Gui.ShowFileTree = false
	},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.CloneIntoSubmodule("sub_name", "sub_path")
		shell.GitAddAll()
		shell.Commit("add submodule")

		sub := "sub_path"

		shell.RunCommand([]string{"git", "-C", sub, "branch", "initial"})
		shell.RunCommand([]string{"git", "-C", sub, "commit", "--allow-empty", "-m", "s1"})
		shell.RunCommand([]string{"git", "add", sub})
		shell.Commit("base at s1")

		shell.RunCommand([]string{"git", "checkout", "-b", "ours"})
		shell.RunCommand([]string{"git", "-C", sub, "checkout", "initial"})
		shell.RunCommand([]string{"git", "add", sub})
		shell.Commit("ours rewinds submodule")

		shell.RunCommand([]string{"git", "checkout", "-b", "theirs", "HEAD~1"})
		shell.RunCommand([]string{"git", "-C", sub, "checkout", "master"})
		shell.RunCommand([]string{"git", "-C", sub, "commit", "--allow-empty", "-m", "s2"})
		shell.RunCommand([]string{"git", "add", sub})
		shell.Commit("theirs advances submodule")

		shell.RunCommand([]string{"git", "checkout", "ours"})
		shell.RunCommand([]string{"git", "-C", sub, "checkout", "initial"})
		shell.RunCommandExpectError([]string{"git", "merge", "theirs"})
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().
			Focus().
			Lines(
				Contains("UU sub_path (submodule)").IsSelected(),
			).
			Tap(func() {

				t.Views().Main().Content(
					Contains("Current changes:").Contains("first commit").
						Contains("Incoming changes:").Contains("s1").Contains("s2"),
				)
			})
	},
})
View Source
var Stage = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Stage and unstage a submodule that has both a new commit and dirty content. The new commit can be staged, but the dirty content can't, so unstaging must still work; this must hold for both the stage (space) and stage-all (a) keybindings.",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Gui.ShowFileTree = false
	},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.CloneIntoSubmodule("my_submodule_name", "my_submodule_path")
		shell.GitAddAll()
		shell.Commit("add submodule")

		shell.RunCommand([]string{"git", "-C", "my_submodule_path", "commit", "--allow-empty", "-m", "submodule commit"})
		shell.CreateFile("my_submodule_path/dirty_file", "dirty content")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().Focus().
			Lines(
				Equals(" M my_submodule_path (submodule)").IsSelected(),
			).
			PressPrimaryAction().
			Lines(
				Equals("MM my_submodule_path (submodule)").IsSelected(),
			).
			PressPrimaryAction().
			Lines(
				Equals(" M my_submodule_path (submodule)").IsSelected(),
			).
			Press(keys.Files.ToggleStagedAll).
			Lines(
				Equals("MM my_submodule_path (submodule)").IsSelected(),
			).
			Press(keys.Files.ToggleStagedAll).
			Lines(
				Equals(" M my_submodule_path (submodule)").IsSelected(),
			)
	},
})
View Source
var StageAllWithDirtySubmodule = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "A submodule with only dirty content (which can't be staged) must not break the stage-all toggle: pressing it repeatedly should keep toggling the other files between staged and unstaged.",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Gui.ShowFileTree = false
	},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.CloneIntoSubmodule("my_submodule_name", "my_submodule_path")
		shell.GitAddAll()
		shell.Commit("add submodule")

		shell.CreateFile("my_submodule_path/dirty_file", "dirty content")
		shell.CreateFile("regular_file", "content")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().Focus().
			Lines(
				Equals(" M my_submodule_path (submodule)"),
				Equals("?? regular_file"),
			).
			Press(keys.Files.ToggleStagedAll).
			Lines(
				Equals(" M my_submodule_path (submodule)"),
				Equals("A  regular_file"),
			).
			Press(keys.Files.ToggleStagedAll).
			Lines(
				Equals(" M my_submodule_path (submodule)"),
				Equals("?? regular_file"),
			)
	},
})
View Source
var StageDirtyOnly = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Pressing space on a submodule that only has dirty content (no new commit) can't stage anything, so we explain that with an error instead of silently doing nothing.",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig: func(config *config.AppConfig) {
		config.GetUserConfig().Gui.ShowFileTree = false
	},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.CloneIntoSubmodule("my_submodule_name", "my_submodule_path")
		shell.GitAddAll()
		shell.Commit("add submodule")

		shell.CreateFile("my_submodule_path/dirty_file", "dirty content")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Files().Focus().
			Lines(
				Equals(" M my_submodule_path (submodule)").IsSelected(),
			).
			PressPrimaryAction().
			Tap(func() {
				t.ExpectPopup().Alert().
					Title(Equals("Error")).
					Content(Contains("Nothing to stage")).
					Confirm()
			}).
			Lines(
				Equals(" M my_submodule_path (submodule)").IsSelected(),
			).
			Press(keys.Files.ToggleStagedAll).
			Tap(func() {
				t.ExpectPopup().Alert().
					Title(Equals("Error")).
					Content(Contains("Nothing to stage")).
					Confirm()
			}).
			Lines(
				Equals(" M my_submodule_path (submodule)").IsSelected(),
			)
	},
})

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