mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-23 00:39:13 +02:00
Merge pull request #2715 from jesseduffield/recent-repos
This commit is contained in:
@ -120,6 +120,11 @@ func NewApp(config config.AppConfigurer, common *common.Common) (*App, error) {
|
|||||||
return app, err
|
return app, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used for testing purposes
|
||||||
|
if os.Getenv("SHOW_RECENT_REPOS") == "true" {
|
||||||
|
showRecentRepos = true
|
||||||
|
}
|
||||||
|
|
||||||
app.Gui, err = gui.NewGui(common, config, gitVersion, updater, showRecentRepos, dirName)
|
app.Gui, err = gui.NewGui(common, config, gitVersion, updater, showRecentRepos, dirName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return app, err
|
return app, err
|
||||||
|
@ -179,7 +179,7 @@ func (gui *Gui) onInitialViewsCreationForRepo() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initialContext := gui.c.CurrentSideContext()
|
initialContext := gui.c.CurrentContext()
|
||||||
if err := gui.c.ActivateContext(initialContext); err != nil {
|
if err := gui.c.ActivateContext(initialContext); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -187,6 +187,11 @@ func getLazygitCommand(test *IntegrationTest, paths Paths, rootDir string, sandb
|
|||||||
if sandbox {
|
if sandbox {
|
||||||
cmdObj.AddEnvVars(fmt.Sprintf("%s=%s", SANDBOX_ENV_VAR, "true"))
|
cmdObj.AddEnvVars(fmt.Sprintf("%s=%s", SANDBOX_ENV_VAR, "true"))
|
||||||
}
|
}
|
||||||
|
if test.ExtraEnvVars() != nil {
|
||||||
|
for key, value := range test.ExtraEnvVars() {
|
||||||
|
cmdObj.AddEnvVars(fmt.Sprintf("%s=%s", key, value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if keyPressDelay > 0 {
|
if keyPressDelay > 0 {
|
||||||
cmdObj.AddEnvVars(fmt.Sprintf("KEY_PRESS_DELAY=%d", keyPressDelay))
|
cmdObj.AddEnvVars(fmt.Sprintf("KEY_PRESS_DELAY=%d", keyPressDelay))
|
||||||
|
@ -23,6 +23,7 @@ type IntegrationTest struct {
|
|||||||
name string
|
name string
|
||||||
description string
|
description string
|
||||||
extraCmdArgs []string
|
extraCmdArgs []string
|
||||||
|
extraEnvVars map[string]string
|
||||||
skip bool
|
skip bool
|
||||||
setupRepo func(shell *Shell)
|
setupRepo func(shell *Shell)
|
||||||
setupConfig func(config *config.AppConfig)
|
setupConfig func(config *config.AppConfig)
|
||||||
@ -47,7 +48,8 @@ type NewIntegrationTestArgs struct {
|
|||||||
// additional args passed to lazygit
|
// additional args passed to lazygit
|
||||||
ExtraCmdArgs []string
|
ExtraCmdArgs []string
|
||||||
// for when a test is flakey
|
// for when a test is flakey
|
||||||
Skip bool
|
ExtraEnvVars map[string]string
|
||||||
|
Skip bool
|
||||||
// to run a test only on certain git versions
|
// to run a test only on certain git versions
|
||||||
GitVersion GitVersionRestriction
|
GitVersion GitVersionRestriction
|
||||||
}
|
}
|
||||||
@ -112,6 +114,7 @@ func NewIntegrationTest(args NewIntegrationTestArgs) *IntegrationTest {
|
|||||||
name: name,
|
name: name,
|
||||||
description: args.Description,
|
description: args.Description,
|
||||||
extraCmdArgs: args.ExtraCmdArgs,
|
extraCmdArgs: args.ExtraCmdArgs,
|
||||||
|
extraEnvVars: args.ExtraEnvVars,
|
||||||
skip: args.Skip,
|
skip: args.Skip,
|
||||||
setupRepo: args.SetupRepo,
|
setupRepo: args.SetupRepo,
|
||||||
setupConfig: args.SetupConfig,
|
setupConfig: args.SetupConfig,
|
||||||
@ -132,6 +135,10 @@ func (self *IntegrationTest) ExtraCmdArgs() []string {
|
|||||||
return self.extraCmdArgs
|
return self.extraCmdArgs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *IntegrationTest) ExtraEnvVars() map[string]string {
|
||||||
|
return self.extraEnvVars
|
||||||
|
}
|
||||||
|
|
||||||
func (self *IntegrationTest) Skip() bool {
|
func (self *IntegrationTest) Skip() bool {
|
||||||
return self.skip
|
return self.skip
|
||||||
}
|
}
|
||||||
|
28
pkg/integration/tests/misc/recent_repos_on_launch.go
Normal file
28
pkg/integration/tests/misc/recent_repos_on_launch.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package misc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Couldn't find an easy way to actually reproduce the situation of opening outside a repo,
|
||||||
|
// so I'm introducing a hacky env var to force lazygit to show the recent repos meu upon opening.
|
||||||
|
|
||||||
|
var RecentReposOnLaunch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "When opening opening to a menu, focus is correctly given to the menu",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
ExtraEnvVars: map[string]string{
|
||||||
|
"SHOW_RECENT_REPOS": "true",
|
||||||
|
},
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
|
SetupRepo: func(shell *Shell) {},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.ExpectPopup().Menu().
|
||||||
|
Title(Equals("Recent repositories")).
|
||||||
|
Select(Contains("Cancel")).
|
||||||
|
Confirm()
|
||||||
|
|
||||||
|
t.Views().Files().IsFocused()
|
||||||
|
},
|
||||||
|
})
|
@ -120,6 +120,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
interactive_rebase.SwapWithConflict,
|
interactive_rebase.SwapWithConflict,
|
||||||
misc.ConfirmOnQuit,
|
misc.ConfirmOnQuit,
|
||||||
misc.InitialOpen,
|
misc.InitialOpen,
|
||||||
|
misc.RecentReposOnLaunch,
|
||||||
patch_building.Apply,
|
patch_building.Apply,
|
||||||
patch_building.ApplyInReverse,
|
patch_building.ApplyInReverse,
|
||||||
patch_building.ApplyInReverseWithConflict,
|
patch_building.ApplyInReverseWithConflict,
|
||||||
|
Reference in New Issue
Block a user