| 
 | 1 | +package commit  | 
 | 2 | + | 
 | 3 | +import (  | 
 | 4 | +	"github.com/jesseduffield/lazygit/pkg/config"  | 
 | 5 | +	. "github.com/jesseduffield/lazygit/pkg/integration/components"  | 
 | 6 | +)  | 
 | 7 | + | 
 | 8 | +var DiscardSubmoduleChanges = NewIntegrationTest(NewIntegrationTestArgs{  | 
 | 9 | +	Description:  "Discarding changes to a submodule from an old commit.",  | 
 | 10 | +	ExtraCmdArgs: []string{},  | 
 | 11 | +	Skip:         false,  | 
 | 12 | +	SetupConfig:  func(config *config.AppConfig) {},  | 
 | 13 | +	SetupRepo: func(shell *Shell) {  | 
 | 14 | +		shell.EmptyCommit("Initial commit")  | 
 | 15 | +		shell.CloneIntoSubmodule("submodule", "submodule")  | 
 | 16 | +		shell.Commit("Add submodule")  | 
 | 17 | + | 
 | 18 | +		shell.AddFileInWorktreeOrSubmodule("submodule", "file", "content")  | 
 | 19 | +		shell.CommitInWorktreeOrSubmodule("submodule", "add file in submodule")  | 
 | 20 | +		shell.GitAdd("submodule")  | 
 | 21 | +		shell.Commit("Update submodule")  | 
 | 22 | + | 
 | 23 | +		shell.UpdateFileInWorktreeOrSubmodule("submodule", "file", "changed content")  | 
 | 24 | +		shell.CommitInWorktreeOrSubmodule("submodule", "change file in submodule")  | 
 | 25 | +		shell.GitAdd("submodule")  | 
 | 26 | +		shell.Commit("Update submodule again")  | 
 | 27 | +	},  | 
 | 28 | +	Run: func(t *TestDriver, keys config.KeybindingConfig) {  | 
 | 29 | +		t.Views().Commits().  | 
 | 30 | +			Focus().  | 
 | 31 | +			Lines(  | 
 | 32 | +				Contains("Update submodule again").IsSelected(),  | 
 | 33 | +				Contains("Update submodule"),  | 
 | 34 | +				Contains("Add submodule"),  | 
 | 35 | +				Contains("Initial commit"),  | 
 | 36 | +			).  | 
 | 37 | +			PressEnter()  | 
 | 38 | + | 
 | 39 | +		t.Views().CommitFiles().  | 
 | 40 | +			IsFocused().  | 
 | 41 | +			Lines(  | 
 | 42 | +				Equals("M submodule").IsSelected(),  | 
 | 43 | +			).  | 
 | 44 | +			Press(keys.Universal.Remove)  | 
 | 45 | + | 
 | 46 | +		t.ExpectPopup().Confirmation().  | 
 | 47 | +			Title(Equals("Discard file changes")).  | 
 | 48 | +			Content(Contains("Are you sure you want to remove changes to the selected file(s) from this commit?")).  | 
 | 49 | +			Confirm()  | 
 | 50 | + | 
 | 51 | +		t.Shell().RunCommand([]string{"git", "submodule", "update"})  | 
 | 52 | +		/* EXPECTED:  | 
 | 53 | +		t.FileSystem().FileContent("submodule/file", Equals("content"))  | 
 | 54 | +		ACTUAL: */  | 
 | 55 | +		t.FileSystem().PathNotPresent("submodule/file")  | 
 | 56 | +	},  | 
 | 57 | +})  | 
0 commit comments