Skip to content

Commit

Permalink
fix(cli): resolve against cwd separately (#1474)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahdietz authored Feb 14, 2025
1 parent cd0f8a1 commit 6206451
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/api-linter/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,21 @@ func (c *cli) lint(rules lint.RuleRegistry, configs lint.Configs) error {
},
}
// Resolve file absolute paths to relative ones.
// Using supplied import paths first.
protoFiles, err := protoparse.ResolveFilenames(c.ProtoImportPaths, c.ProtoFiles...)
if err != nil {
return err
}
// Then resolve again against ".", the local directory.
// This is necessary because ResolveFilenames won't resolve a path if it
// relative to *at least one* of the given import paths, which can result
// in duplicate file parsing and compilation errors, as seen in #1465 and
// #1471. So we resolve against local (default) and flag specified import
// paths separately.
protoFiles, err = protoparse.ResolveFilenames([]string{"."}, protoFiles...)
if err != nil {
return err
}
fd, err := p.ParseFiles(protoFiles...)
if err != nil {
if err == protoparse.ErrInvalidSource {
Expand Down

0 comments on commit 6206451

Please sign in to comment.