summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoritz Haase <Moritz.Haase@bmw.de>2022-03-26 18:10:58 +0100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-27 10:14:33 +1100
commit240483953f708f538b3396fa9e21069c1461137c (patch)
treeb41fdcc02e1b128ea5d4cdd6374a5e4f48829f05
parent51baa8c17dddd59b4640aec10758dafb586a612e (diff)
config: Add option 'git.autoRefresh' to en-/disable auto-refresh
Adds a new 'autoRefresh' option to the 'git' config section that allows user to disable auto-refresh (defaults to on). If auto-refresh is enabled, the refreshInterval is now checked before starting the timer to prevent crashes when it is non-positive. Fixes #1417
-rw-r--r--docs/Config.md3
-rw-r--r--pkg/config/user_config.go2
-rw-r--r--pkg/gui/gui.go11
3 files changed, 14 insertions, 2 deletions
diff --git a/docs/Config.md b/docs/Config.md
index aac7f0349..951686073 100644
--- a/docs/Config.md
+++ b/docs/Config.md
@@ -73,6 +73,7 @@ git:
showGraph: 'when-maximised'
skipHookPrefix: WIP
autoFetch: true
+ autoRefresh: true
branchLogCmd: 'git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --'
allBranchesLogCmd: 'git log --graph --all --color=always --abbrev-commit --decorate --date=relative --pretty=medium'
overrideGpg: false # prevents lazygit from spawning a separate process when using GPG
@@ -84,7 +85,7 @@ os:
editCommandTemplate: '{{editor}} {{filename}}'
openCommand: ''
refresher:
- refreshInterval: 10 # file/submodule refresh interval in seconds
+ refreshInterval: 10 # File/submodule refresh interval in seconds. Auto-refresh can be disabled via option 'git.autoRefresh'.
fetchInterval: 60 # re-fetch interval in seconds
update:
method: prompt # can be: prompt | background | never
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go
index 988673f1e..321a7fa5e 100644
--- a/pkg/config/user_config.go
+++ b/pkg/config/user_config.go
@@ -68,6 +68,7 @@ type GitConfig struct {
Merging MergingConfig `yaml:"merging"`
SkipHookPrefix string `yaml:"skipHookPrefix"`
AutoFetch bool `yaml:"autoFetch"`
+ AutoRefresh bool `yaml:"autoRefresh"`
BranchLogCmd string `yaml:"branchLogCmd"`
AllBranchesLogCmd string `yaml:"allBranchesLogCmd"`
OverrideGpg bool `yaml:"overrideGpg"`
@@ -373,6 +374,7 @@ func GetDefaultConfig() *UserConfig {
},
SkipHookPrefix: "WIP",
AutoFetch: true,
+ AutoRefresh: true,
BranchLogCmd: "git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --",
AllBranchesLogCmd: "git log --graph --all --color=always --abbrev-commit --decorate --date=relative --pretty=medium",
DisableForcePushing: false,
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index b4e0f8de4..3848f2bd9 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -587,7 +587,16 @@ func (gui *Gui) Run(filterPath string) error {
go utils.Safe(gui.startBackgroundFetch)
}
- gui.goEvery(time.Second*time.Duration(userConfig.Refresher.RefreshInterval), gui.stopChan, gui.refreshFilesAndSubmodules)
+ if userConfig.Git.AutoRefresh {
+ refreshInterval := userConfig.Refresher.RefreshInterval
+ if refreshInterval > 0 {
+ gui.goEvery(time.Second*time.Duration(refreshInterval), gui.stopChan, gui.refreshFilesAndSubmodules)
+ } else {
+ gui.c.Log.Errorf(
+ "Value of config option 'refresher.refreshInterval' (%d) is invalid, disabling auto-refresh",
+ refreshInterval)
+ }
+ }
gui.c.Log.Info("starting main loop")