Skip to content

Commit

Permalink
Use gel.toml if one exists (#327)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Frederick <[email protected]>
  • Loading branch information
fantix and fmoor authored Jan 2, 2025
1 parent c1dfe1c commit 670c1df
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
10 changes: 9 additions & 1 deletion cmd/edgeql-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,20 @@ func getProject() (*project, error) {
)
}

file := filepath.Join(dir, "edgedb.toml")
file := filepath.Join(dir, "gel.toml")
isTOML, err := isEdgeDBTOML(file)
if err != nil {
return nil, err
}

if !isTOML {
file = filepath.Join(dir, "edgedb.toml")
isTOML, err = isEdgeDBTOML(file)
if err != nil {
return nil, err
}
}

if isTOML {
data, err := os.ReadFile(file)
if err != nil {
Expand Down
50 changes: 27 additions & 23 deletions internal/client/connutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ func (r *configResolver) resolveTOML(paths *cfgPaths) error {
}

if !exists(stashDir) {
return errors.New("Found `edgedb.toml` " +
return errors.New("Found `gel.toml` " +
"but the project is not initialized. Run `edgedb project init`.")
}

Expand Down Expand Up @@ -1465,33 +1465,37 @@ func findEdgeDBTOML(paths *cfgPaths) (string, error) {
}

for {
tomlPath := filepath.Join(dir, "edgedb.toml")
tomlPath := filepath.Join(dir, "gel.toml")
if _, e := os.Stat(tomlPath); os.IsNotExist(e) {
parent := filepath.Dir(dir)
// Stop searching when dir is the root directory.
if parent == dir {
return "", errNoTOMLFound
}
tomlPath = filepath.Join(dir, "edgedb.toml")
if _, e := os.Stat(tomlPath); os.IsNotExist(e) {
parent := filepath.Dir(dir)
// Stop searching when dir is the root directory.
if parent == dir {
return "", errNoTOMLFound
}

pDev, err := device(parent)
if err != nil {
return "", fmt.Errorf(
"searching for edgedb.toml in or above %q: %w",
filepath.Dir(tomlPath), err)
}
pDev, err := device(parent)
if err != nil {
return "", fmt.Errorf(
"searching for gel.toml in or above %q: %w",
filepath.Dir(tomlPath), err)
}

// Stop searching at file system boundaries.
if pDev != dev {
if err == nil { // nolint:govet
err = errNoTOMLFound
// Stop searching at file system boundaries.
if pDev != dev {
if err == nil { // nolint:govet
err = errNoTOMLFound
}
return "", fmt.Errorf(
"%w: stopped searching for gel.toml "+
"at file system boundary %q", err, dir)
}
return "", fmt.Errorf("%w: stopped searching for edgedb.toml "+
"at file system boundary %q", err, dir)
}

dir = parent
dev = pDev
continue
dir = parent
dev = pDev
continue
}
}
return tomlPath, nil
}
Expand Down

0 comments on commit 670c1df

Please sign in to comment.