diff --git a/docs-master/Config.md b/docs-master/Config.md index fa6b3eeac..80f8cfd23 100644 --- a/docs-master/Config.md +++ b/docs-master/Config.md @@ -414,6 +414,11 @@ git: # If true, periodically refresh files and submodules autoRefresh: true + # If true, poll the repo periodically for external ref changes (commits, branch + # updates, checkouts made outside lazygit) and refresh when one is detected. + # Independent of autoRefresh, which only governs the files panel. + autoDetectExternalChanges: true + # If not "none", lazygit will automatically fast-forward local branches to match # their upstream after fetching. Applies to branches that are not the currently # checked out branch, and only to those that are strictly behind their upstream @@ -525,6 +530,11 @@ refresher: # Auto-fetch can be disabled via option 'git.autoFetch'. fetchInterval: 60 + # Interval in seconds at which lazygit polls for external ref changes (commits, + # branch updates, checkouts made outside lazygit). + # Detection can be disabled via option 'git.autoDetectExternalChanges'. + externalChangeCheckInterval: 2 + # If true, show a confirmation popup before quitting Lazygit confirmOnQuit: false diff --git a/pkg/config/app_config_test.go b/pkg/config/app_config_test.go index 1109256a9..8e6c85f32 100644 --- a/pkg/config/app_config_test.go +++ b/pkg/config/app_config_test.go @@ -654,6 +654,12 @@ git: # If true, periodically refresh files and submodules autoRefresh: true + # If true, poll the repo periodically for external ref changes (commits, + # branch updates, checkouts made outside lazygit) and refresh when one + # is detected. Independent of autoRefresh, which only governs the files + # panel. + autoDetectExternalChanges: true + # If true, pass the --all arg to git fetch fetchAll: true @@ -723,6 +729,11 @@ refresher: # Auto-fetch can be disabled via option 'git.autoFetch'. fetchInterval: 60 + # Interval in seconds at which lazygit polls for external ref changes + # (commits, branch updates, checkouts made outside lazygit). + # Detection can be disabled via option 'git.autoDetectExternalChanges'. + externalChangeCheckInterval: 2 + # If true, show a confirmation popup before quitting Lazygit confirmOnQuit: false diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 0f0b4792f..e96f4aff4 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -48,6 +48,9 @@ type RefresherConfig struct { // Re-fetch interval in seconds. // Auto-fetch can be disabled via option 'git.autoFetch'. FetchInterval int `yaml:"fetchInterval" jsonschema:"exclusiveMinimum=0"` + // Interval in seconds at which lazygit polls for external ref changes (commits, branch updates, checkouts made outside lazygit). + // Detection can be disabled via option 'git.autoDetectExternalChanges'. + ExternalChangeCheckInterval int `yaml:"externalChangeCheckInterval" jsonschema:"exclusiveMinimum=0"` } func (c *RefresherConfig) RefreshIntervalDuration() time.Duration { @@ -58,6 +61,10 @@ func (c *RefresherConfig) FetchIntervalDuration() time.Duration { return time.Second * time.Duration(c.FetchInterval) } +func (c *RefresherConfig) ExternalChangeCheckIntervalDuration() time.Duration { + return time.Second * time.Duration(c.ExternalChangeCheckInterval) +} + type GuiConfig struct { // See https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#custom-author-color AuthorColors map[string]string `yaml:"authorColors"` @@ -296,6 +303,8 @@ type GitConfig struct { AutoFetch bool `yaml:"autoFetch"` // If true, periodically refresh files and submodules AutoRefresh bool `yaml:"autoRefresh"` + // If true, poll the repo periodically for external ref changes (commits, branch updates, checkouts made outside lazygit) and refresh when one is detected. Independent of autoRefresh, which only governs the files panel. + AutoDetectExternalChanges bool `yaml:"autoDetectExternalChanges"` // If not "none", lazygit will automatically fast-forward local branches to match their upstream after fetching. Applies to branches that are not the currently checked out branch, and only to those that are strictly behind their upstream (as opposed to diverged). // Possible values: 'none' | 'onlyMainBranches' | 'allBranches' AutoForwardBranches string `yaml:"autoForwardBranches" jsonschema:"enum=none,enum=onlyMainBranches,enum=allBranches"` @@ -922,6 +931,7 @@ func GetDefaultConfigForPlatform(platform string) *UserConfig { MainBranches: []string{"master", "main"}, AutoFetch: true, AutoRefresh: true, + AutoDetectExternalChanges: true, AutoForwardBranches: "onlyMainBranches", FetchAll: true, AutoStageResolvedConflicts: true, @@ -937,8 +947,9 @@ func GetDefaultConfigForPlatform(platform string) *UserConfig { TruncateCopiedCommitHashesTo: 12, }, Refresher: RefresherConfig{ - RefreshInterval: 10, - FetchInterval: 60, + RefreshInterval: 10, + FetchInterval: 60, + ExternalChangeCheckInterval: 2, }, Update: UpdateConfig{ Method: "prompt", diff --git a/schema-master/config.json b/schema-master/config.json index ff50ab185..e0871940c 100644 --- a/schema-master/config.json +++ b/schema-master/config.json @@ -358,6 +358,11 @@ "description": "If true, periodically refresh files and submodules", "default": true }, + "autoDetectExternalChanges": { + "type": "boolean", + "description": "If true, poll the repo periodically for external ref changes (commits, branch updates, checkouts made outside lazygit) and refresh when one is detected. Independent of autoRefresh, which only governs the files panel.", + "default": true + }, "autoForwardBranches": { "type": "string", "enum": [ @@ -3548,6 +3553,12 @@ "exclusiveMinimum": 0, "description": "Re-fetch interval in seconds.\nAuto-fetch can be disabled via option 'git.autoFetch'.", "default": 60 + }, + "externalChangeCheckInterval": { + "type": "integer", + "exclusiveMinimum": 0, + "description": "Interval in seconds at which lazygit polls for external ref changes (commits, branch updates, checkouts made outside lazygit).\nDetection can be disabled via option 'git.autoDetectExternalChanges'.", + "default": 2 } }, "additionalProperties": false,