Skip to content

Commit

Permalink
fix: patch support for dir named workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellzc committed Aug 14, 2023
1 parent adce430 commit 86a4c72
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/gazelle/fix-update.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main
import (
"bytes"
"context"
"errors"
"flag"
"fmt"
"io/ioutil"
Expand All @@ -26,6 +27,7 @@ import (
"path/filepath"
"sort"
"strings"
"syscall"

"github.com/bazelbuild/bazel-gazelle/config"
gzflag "github.com/bazelbuild/bazel-gazelle/flag"
Expand Down Expand Up @@ -142,7 +144,7 @@ func (ucr *updateConfigurer) CheckFlags(fs *flag.FlagSet, c *config.Config) erro
ucr.repoConfigPath = wspace.FindWORKSPACEFile(c.RepoRoot)
}
repoConfigFile, err := rule.LoadWorkspaceFile(ucr.repoConfigPath, "")
if err != nil && !os.IsNotExist(err) {
if err != nil && !os.IsNotExist(err) && !isDirErr(err) {
return err
} else if err == nil {
c.Repos, _, err = repo.ListRepositories(repoConfigFile)
Expand Down Expand Up @@ -741,3 +743,14 @@ func appendOrMergeKindMapping(mappedLoads []rule.LoadInfo, mappedKind config.Map
Symbols: []string{mappedKind.KindName},
})
}

func isDirErr(err error) bool {
if err == nil {
return false
}
var pe *os.PathError
if errors.As(err, &pe) {
return pe.Err == syscall.EISDIR
}
return false
}

0 comments on commit 86a4c72

Please sign in to comment.