1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-17 21:18:31 +02:00

Merge pull request #2715 from jesseduffield/recent-repos

This commit is contained in:
Jesse Duffield 2023-06-07 18:33:05 +10:00 committed by GitHub
commit 0080684c7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 2 deletions

View File

@ -120,6 +120,11 @@ func NewApp(config config.AppConfigurer, common *common.Common) (*App, error) {
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)
if err != nil {
return app, err

View File

@ -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 {
return err
}

View File

@ -187,6 +187,11 @@ func getLazygitCommand(test *IntegrationTest, paths Paths, rootDir string, sandb
if sandbox {
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 {
cmdObj.AddEnvVars(fmt.Sprintf("KEY_PRESS_DELAY=%d", keyPressDelay))

View File

@ -23,6 +23,7 @@ type IntegrationTest struct {
name string
description string
extraCmdArgs []string
extraEnvVars map[string]string
skip bool
setupRepo func(shell *Shell)
setupConfig func(config *config.AppConfig)
@ -47,7 +48,8 @@ type NewIntegrationTestArgs struct {
// additional args passed to lazygit
ExtraCmdArgs []string
// for when a test is flakey
Skip bool
ExtraEnvVars map[string]string
Skip bool
// to run a test only on certain git versions
GitVersion GitVersionRestriction
}
@ -112,6 +114,7 @@ func NewIntegrationTest(args NewIntegrationTestArgs) *IntegrationTest {
name: name,
description: args.Description,
extraCmdArgs: args.ExtraCmdArgs,
extraEnvVars: args.ExtraEnvVars,
skip: args.Skip,
setupRepo: args.SetupRepo,
setupConfig: args.SetupConfig,
@ -132,6 +135,10 @@ func (self *IntegrationTest) ExtraCmdArgs() []string {
return self.extraCmdArgs
}
func (self *IntegrationTest) ExtraEnvVars() map[string]string {
return self.extraEnvVars
}
func (self *IntegrationTest) Skip() bool {
return self.skip
}

View 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()
},
})

View File

@ -120,6 +120,7 @@ var tests = []*components.IntegrationTest{
interactive_rebase.SwapWithConflict,
misc.ConfirmOnQuit,
misc.InitialOpen,
misc.RecentReposOnLaunch,
patch_building.Apply,
patch_building.ApplyInReverse,
patch_building.ApplyInReverseWithConflict,