summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-06-07 18:33:05 +1000
committerGitHub <noreply@github.com>2023-06-07 18:33:05 +1000
commit0080684c7c3db101aaaf1b54c501c0a6e24ba54a (patch)
treeef4ffb70231341848698a1750c6d7821b8ac27ff
parentb6a31369da3f42c1254f6d5ba0ca4e4cb79f42f7 (diff)
parentc92e687d3bb405086c66c47475359e304ed42166 (diff)
Merge pull request #2715 from jesseduffield/recent-repos
-rw-r--r--pkg/app/app.go5
-rw-r--r--pkg/gui/layout.go2
-rw-r--r--pkg/integration/components/runner.go5
-rw-r--r--pkg/integration/components/test.go9
-rw-r--r--pkg/integration/tests/misc/recent_repos_on_launch.go28
-rw-r--r--pkg/integration/tests/test_list.go1
6 files changed, 48 insertions, 2 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go
index e77d2868c..59730780d 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -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
diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go
index 35dbe55b7..88ddeca5f 100644
--- a/pkg/gui/layout.go
+++ b/pkg/gui/layout.go
@@ -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
}
diff --git a/pkg/integration/components/runner.go b/pkg/integration/components/runner.go
index f1f8e3c89..9a787c864 100644
--- a/pkg/integration/components/runner.go
+++ b/pkg/integration/components/runner.go
@@ -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))
diff --git a/pkg/integration/components/test.go b/pkg/integration/components/test.go
index 648c6ed41..464779e38 100644
--- a/pkg/integration/components/test.go
+++ b/pkg/integration/components/test.go
@@ -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
}
diff --git a/pkg/integration/tests/misc/recent_repos_on_launch.go b/pkg/integration/tests/misc/recent_repos_on_launch.go
new file mode 100644
index 000000000..dc0287261
--- /dev/null
+++ b/pkg/integration/tests/misc/recent_repos_on_launch.go
@@ -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()
+ },
+})
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index 222917b0f..7a5ed71b4 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -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,