submodule

package
v0.38.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Add = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Add a submodule",
	ExtraCmdArgs: "",
	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(
				Contains(".gitmodules").IsSelected(),
				Contains("my_submodule_path (submodule)"),
			).
			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: "",
	Skip:         false,
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.UserConfig.CustomCommands = []config.CustomCommand{
			{
				Key:     "e",
				Context: "files",
				Command: "git commit --allow-empty -m \"empty commit\"",
			},
		}
	},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.CloneIntoSubmodule("my_submodule")
		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"))
		}

		assertInParentRepo()

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

		assertInSubmodule()

		t.Views().Files().IsFocused().
			Press("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 \(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 Remove = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Remove a submodule",
	ExtraCmdArgs: "",
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("first commit")
		shell.CloneIntoSubmodule("my_submodule")
		shell.GitAddAll()
		shell.Commit("add submodule")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Submodules().Focus().
			Lines(
				Contains("my_submodule").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' and its corresponding directory? This is irreversible.")).
					Confirm()
			}).
			IsEmpty()

		t.Views().Files().Focus().
			Lines(
				MatchesRegexp(`M.*\.gitmodules`).IsSelected(),
				MatchesRegexp(`D.*my_submodule`),
			)

		t.Views().Main().Content(
			Contains("-[submodule \"my_submodule\"]").
				Contains("-   path = my_submodule").
				Contains("-   url = ../other_repo"),
		)
	},
})
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: "",
	Skip:         false,
	SetupConfig: func(cfg *config.AppConfig) {
		cfg.UserConfig.CustomCommands = []config.CustomCommand{
			{
				Key:     "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")
		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"))
		}

		assertInParentRepo()

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

		assertInSubmodule()

		t.Views().Status().Content(Contains("my_submodule"))

		t.Views().Files().IsFocused().
			Press("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 contains modified content"))

		t.Views().Files().Focus().
			Lines(
				MatchesRegexp(` M.*my_submodule \(submodule\)`).IsSelected(),
			).
			Press(keys.Universal.Remove).
			Tap(func() {
				t.ExpectPopup().Menu().Title(Equals("my_submodule")).Select(Contains("stash uncommitted submodule changes and update")).Confirm()
			}).
			IsEmpty()

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

		assertInSubmodule()

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

		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"))
	},
})

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