File: discard_submodule_changes.go

package info (click to toggle)
lazygit 0.57.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,748 kB
  • sloc: sh: 153; makefile: 76
file content (54 lines) | stat: -rw-r--r-- 1,719 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package commit

import (
	"github.com/jesseduffield/lazygit/pkg/config"
	. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var DiscardSubmoduleChanges = NewIntegrationTest(NewIntegrationTestArgs{
	Description:  "Discarding changes to a submodule from an old commit.",
	ExtraCmdArgs: []string{},
	Skip:         false,
	SetupConfig:  func(config *config.AppConfig) {},
	SetupRepo: func(shell *Shell) {
		shell.EmptyCommit("Initial commit")
		shell.CloneIntoSubmodule("submodule", "submodule")
		shell.Commit("Add submodule")

		shell.AddFileInWorktreeOrSubmodule("submodule", "file", "content")
		shell.CommitInWorktreeOrSubmodule("submodule", "add file in submodule")
		shell.GitAdd("submodule")
		shell.Commit("Update submodule")

		shell.UpdateFileInWorktreeOrSubmodule("submodule", "file", "changed content")
		shell.CommitInWorktreeOrSubmodule("submodule", "change file in submodule")
		shell.GitAdd("submodule")
		shell.Commit("Update submodule again")
	},
	Run: func(t *TestDriver, keys config.KeybindingConfig) {
		t.Views().Commits().
			Focus().
			Lines(
				Contains("Update submodule again").IsSelected(),
				Contains("Update submodule"),
				Contains("Add submodule"),
				Contains("Initial commit"),
			).
			PressEnter()

		t.Views().CommitFiles().
			IsFocused().
			Lines(
				Equals("M submodule").IsSelected(),
			).
			Press(keys.Universal.Remove)

		t.ExpectPopup().Confirmation().
			Title(Equals("Discard file changes")).
			Content(Contains("Are you sure you want to remove changes to the selected file(s) from this commit?")).
			Confirm()

		t.Shell().RunCommand([]string{"git", "submodule", "update"})
		t.FileSystem().FileContent("submodule/file", Equals("content"))
	},
})