From 374fb1e8a591fc146e0684433bf69115e22d66dc Mon Sep 17 00:00:00 2001 From: Amolith Date: Sun, 5 Apr 2026 20:00:30 -0600 Subject: [PATCH] Treat empty environ values as absent in HasEnvSource --- cmd/root.go | 2 -- internal/config/config.go | 4 ++-- internal/config/resolved_test.go | 4 ++-- internal/restic/exec.go | 2 -- internal/ui/screens/snapshot.go | 1 - 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 600ccdcb4a02efcbbfd22b63f7b08372071f0cfb..31d0f9dc22ed4d77aecf6a6dc399a24529f41dc3 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -469,8 +469,6 @@ func promptForCommand(command string, cfg *config.ResolvedConfig) (map[string][] } } - - // includeFlags lists the restic flags that provide explicit file // selection for restore. When any of these are already present in the // resolved config, the interactive file picker is skipped — the user diff --git a/internal/config/config.go b/internal/config/config.go index 3681b3e35cd40a2fa7d501b637729c39ed7e2d3e..148846159a082c1995cd8780cf393e4914eb507d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -84,10 +84,10 @@ const CommandSuffix = "_COMMAND" // check for it themselves. func (rc *ResolvedConfig) HasEnvSource(key string) bool { if rc.Environ != nil { - if _, ok := rc.Environ[key]; ok { + if v, ok := rc.Environ[key]; ok && v != "" { return true } - if _, ok := rc.Environ[key+CommandSuffix]; ok { + if v, ok := rc.Environ[key+CommandSuffix]; ok && v != "" { return true } } diff --git a/internal/config/resolved_test.go b/internal/config/resolved_test.go index e5da33f5401c88c613b09fd0e3a758bfaabcf717..d6143034223f5192d328fd22fb3b49f4f229a022 100644 --- a/internal/config/resolved_test.go +++ b/internal/config/resolved_test.go @@ -37,10 +37,10 @@ func TestHasEnvSource(t *testing.T) { want: false, }, { - name: "empty string value still counts as present", + name: "empty string value counts as absent", environ: map[string]string{"RESTIC_REPOSITORY": ""}, envKey: "RESTIC_REPOSITORY", - want: true, + want: false, }, { name: "command variant for non-restic key", diff --git a/internal/restic/exec.go b/internal/restic/exec.go index eb0031b7dbbd652d84301888d07a883fb3cc3b5c..8eb753c4f9ead4639e30094448c91f4537dbd524 100644 --- a/internal/restic/exec.go +++ b/internal/restic/exec.go @@ -12,8 +12,6 @@ import ( "git.secluded.site/keld/internal/config" ) - - // resticNativeCommands lists .environ keys that restic handles natively. // Keld passes these through as-is rather than executing them. var resticNativeCommands = map[string]bool{ diff --git a/internal/ui/screens/snapshot.go b/internal/ui/screens/snapshot.go index 053d9511c425e9de93bb89c1da4822418eae4ee2..e9098f4c75263ec13eb0cfeba162cf7abaf6112d 100644 --- a/internal/ui/screens/snapshot.go +++ b/internal/ui/screens/snapshot.go @@ -274,7 +274,6 @@ func (s *Snapshot) rebuildSelectForm() { // theme changes preserve the user's input. Callers that start a fresh // entry (Init, switchToManual) reset s.entered explicitly. func (s *Snapshot) buildManualForm() { - input := huh.NewInput(). Title("Snapshot ID"). Description("Supports snapshotID:subfolder syntax, or \"latest\".").