Skip to content

Commit 560758c

Browse files
committed
update
1 parent 12a6915 commit 560758c

48 files changed

Lines changed: 74 additions & 35 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

go/src/hotel/env_repo/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import (
1717
)
1818

1919
// TODO move to mutable config
20-
const FileWorkspace = ".dodder-workspace"
20+
const (
21+
FileWorkspaceTemplate = ".%s-workspace"
22+
FileWorkspace = ".dodder-workspace"
23+
)
2124

2225
type Env struct {
2326
env_local.Env

go/src/kilo/env_workspace/main.go

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package env_workspace
22

33
import (
4+
"fmt"
45
"path/filepath"
56

67
"code.linenisgreat.com/dodder/go/src/alfa/errors"
78
"code.linenisgreat.com/dodder/go/src/alfa/interfaces"
9+
"code.linenisgreat.com/dodder/go/src/charlie/files"
810
"code.linenisgreat.com/dodder/go/src/echo/env_dir"
911
"code.linenisgreat.com/dodder/go/src/echo/fd"
1012
"code.linenisgreat.com/dodder/go/src/echo/ids"
@@ -64,40 +66,27 @@ func Make(
6466

6567
dir := out.GetCwd()
6668

67-
// TODO add workspace parent tree height limit?
68-
for {
69-
expectedWorkspaceConfigFilePath := filepath.Join(
69+
workspaceFile := out.findWorkspaceFile(dir, env_repo.FileWorkspace)
70+
71+
if workspaceFile == "" {
72+
workspaceFile = out.findWorkspaceFile(
7073
dir,
71-
env_repo.FileWorkspace,
74+
fmt.Sprintf(env_repo.FileWorkspaceTemplate, "zit"),
7275
)
76+
}
7377

78+
if workspaceFile == "" {
79+
out.isTemporary = true
80+
} else {
7481
if err = workspace_config_blobs.DecodeFromFile(
7582
&object,
76-
expectedWorkspaceConfigFilePath,
77-
); errors.IsNotExist(err) {
78-
// if we hit the root, reset to empty so that we trigger the isTemporary
79-
// path
80-
if dir == string(filepath.Separator) {
81-
dir = ""
82-
}
83-
84-
dir = filepath.Dir(dir)
85-
86-
if dir != "." {
87-
continue
88-
}
89-
90-
out.isTemporary = true
91-
err = nil
92-
break
93-
94-
} else if err != nil {
95-
err = errors.BadRequestPrefix("failed to decode `.dodder-workspace`", err)
83+
workspaceFile,
84+
); err != nil {
85+
err = errors.BadRequestf("failed to decode `%s`: %w", workspaceFile, err)
9686
return
97-
} else {
98-
out.blob = *object.Struct
99-
break
10087
}
88+
89+
out.blob = *object.Struct
10190
}
10291

10392
defaults := out.configMutable.GetDefaults()
@@ -165,6 +154,55 @@ type env struct {
165154
store Store
166155
}
167156

157+
func (env *env) findWorkspaceFile(
158+
dir string,
159+
name string,
160+
) (found string) {
161+
// TODO add workspace parent tree height limit?
162+
for {
163+
expectedWorkspaceConfigFilePath := filepath.Join(
164+
dir,
165+
name,
166+
)
167+
168+
if files.Exists(expectedWorkspaceConfigFilePath) {
169+
found = expectedWorkspaceConfigFilePath
170+
return
171+
}
172+
173+
// if we hit the root, reset to empty so that we trigger the isTemporary
174+
// path
175+
if dir == string(filepath.Separator) {
176+
dir = ""
177+
}
178+
179+
dir = filepath.Dir(dir)
180+
181+
if dir != "." {
182+
continue
183+
}
184+
185+
return
186+
}
187+
}
188+
189+
func (env *env) tryLoad(
190+
path string,
191+
object *triple_hyphen_io.TypedStruct[*workspace_config_blobs.Blob],
192+
) (err error) {
193+
if err = workspace_config_blobs.DecodeFromFile(
194+
object,
195+
path,
196+
); err != nil {
197+
err = errors.BadRequestPrefix("failed to decode `.dodder-workspace`", err)
198+
return
199+
}
200+
201+
env.blob = *object.Struct
202+
203+
return
204+
}
205+
168206
func (env *env) GetWorkspaceDir() string {
169207
return env.dir
170208
}

zz-tests_bats/justfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ dir_git_root := shell("git rev-parse --show-toplevel")
77
clean-fixtures:
88
#! /bin/bash -ex
99

10-
pushd "{{dir_git_root}}/pkgs/bravo/dodder/zz-tests_bats" || exit
11-
1210
git reset HEAD migration/v*/
1311
./../bin/chflags.bash -R nouchg migration/v*/
1412
git clean -fd migration/v*/
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
-147 Bytes
Binary file not shown.
Binary file not shown.
-147 Bytes
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)