-
-
Notifications
You must be signed in to change notification settings - Fork 636
fix: support gazelle generation_mode:update_only #2708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,8 @@ import ( | |
|
||
"github.com/emirpasic/gods/lists/singlylinkedlist" | ||
|
||
"github.com/bazelbuild/bazel-gazelle/label" | ||
"github.com/bazel-contrib/rules_python/gazelle/manifest" | ||
"github.com/bazelbuild/bazel-gazelle/label" | ||
) | ||
|
||
// Directives | ||
|
@@ -125,21 +125,28 @@ const ( | |
|
||
// defaultIgnoreFiles is the list of default values used in the | ||
// python_ignore_files option. | ||
var defaultIgnoreFiles = map[string]struct{}{ | ||
} | ||
var defaultIgnoreFiles = map[string]struct{}{} | ||
|
||
// Configs is an extension of map[string]*Config. It provides finding methods | ||
// on top of the mapping. | ||
type Configs map[string]*Config | ||
|
||
// ParentForPackage returns the parent Config for the given Bazel package. | ||
func (c *Configs) ParentForPackage(pkg string) *Config { | ||
dir := path.Dir(pkg) | ||
if dir == "." { | ||
dir = "" | ||
func (c Configs) ParentForPackage(pkg string) *Config { | ||
for { | ||
dir := path.Dir(pkg) | ||
if dir == "." { | ||
dir = "" | ||
} | ||
parent := (map[string]*Config)(c)[dir] | ||
if parent != nil { | ||
return parent | ||
} | ||
if dir == "" { | ||
return nil | ||
} | ||
pkg = dir | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a unit test for this new logic? Just testing the Right now it is a little bit hard to read and having tests would help understand what this has to do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added a few basic tests for this method. There should probably be some additional full tests for |
||
} | ||
parent := (map[string]*Config)(*c)[dir] | ||
return parent | ||
} | ||
|
||
// Config represents a config extension for a specific Bazel package. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The precommit seems to be doing this? 🤷