From 5f9c2c769f4d21e492318aabd77fcb154861fea7 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Mon, 31 Jul 2023 18:00:06 -0400 Subject: [PATCH] default behavior for environment.LoadRoot was returning nil when it should have been returning an env_core.Root stub (#383) --- environment/api.go | 2 +- environment/env_v0_4/root.go | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/environment/api.go b/environment/api.go index 213d9ed4..54addb7e 100644 --- a/environment/api.go +++ b/environment/api.go @@ -13,7 +13,7 @@ func LoadRoot() (env_core.Root, error) { } else if assert, err := env_v0_3.Assert(); assert && err == nil { return env_v0_3.Load() } else { - return nil, err + return env_v0_4.Default() } } diff --git a/environment/env_v0_4/root.go b/environment/env_v0_4/root.go index 2a534339..28804bac 100644 --- a/environment/env_v0_4/root.go +++ b/environment/env_v0_4/root.go @@ -18,6 +18,19 @@ type Root struct { env *env_core.Environment } +func Default() (*Root, error) { + r := &Root{} + root, err := rootDir() + if err != nil { + return nil, err + } + r.meta = &env_core.Metadata{ + V: V, + RootPath: root, + } + return r, nil +} + func Assert() (bool, error) { exists, err := rootExists() if err != nil { @@ -55,14 +68,11 @@ func Load() (*Root, error) { } } else { - root, err := rootDir() + root, err := Default() if err != nil { return nil, err } - r.meta = &env_core.Metadata{ - V: V, - RootPath: root, - } + r = root } return r, nil }