-
Notifications
You must be signed in to change notification settings - Fork 6
Do not duplicate packages when running gazelle-update-repos #47
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
base: main
Are you sure you want to change the base?
Changes from all commits
4729a48
124ad22
966b082
362e862
7388c7e
fed76e2
999e16a
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,7 @@ import ( | |||||
| "github.com/bazelbuild/bazel-gazelle/repo" | ||||||
| "github.com/bazelbuild/bazel-gazelle/resolve" | ||||||
| "github.com/bazelbuild/bazel-gazelle/rule" | ||||||
| bzl "github.com/bazelbuild/buildtools/build" | ||||||
| "github.com/bazelbuild/rules_go/go/tools/bazel" | ||||||
|
|
||||||
| "os" | ||||||
|
|
@@ -80,14 +81,14 @@ var haskellAttrInfo = rule.KindInfo{ | |||||
| MatchAttrs: []string{}, | ||||||
| NonEmptyAttrs: map[string]bool{}, | ||||||
| ResolveAttrs: map[string]bool{ | ||||||
| "ghcopts": true, | ||||||
| "data": true, | ||||||
| "deps": true, | ||||||
| "main_file": true, | ||||||
| "plugins": true, | ||||||
| "srcs": true, | ||||||
| "tools": true, | ||||||
| "version": true, | ||||||
| "ghcopts": true, | ||||||
| "data": true, | ||||||
| "deps": true, | ||||||
| "main_file": true, | ||||||
| "plugins": true, | ||||||
| "srcs": true, | ||||||
| "tools": true, | ||||||
| "version": true, | ||||||
| }, | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -130,7 +131,7 @@ func (*gazelleCabalLang) Imports(c *config.Config, r *rule.Rule, f *rule.File) [ | |||||
| case "haskell_library": | ||||||
| visibility := r.PrivateAttr("visibility") | ||||||
| pkgName := r.PrivateAttr("pkgName") | ||||||
| if visibility == "private" { | ||||||
| if visibility == "private" { | ||||||
| prefix = fmt.Sprintf("private_library:%s:", pkgName) | ||||||
| } else { | ||||||
| prefix = fmt.Sprintf("public_library:%s:", pkgName) | ||||||
|
|
@@ -169,7 +170,7 @@ func (*gazelleCabalLang) GenerateRules(args language.GenerateArgs) language.Gene | |||||
|
|
||||||
| generateResult := infoToRules(args.Config.RepoRoot, ruleInfos) | ||||||
|
|
||||||
| if (args.File != nil) { | ||||||
| if args.File != nil { | ||||||
| copyPrivateAttrs(generateResult.Gen, args.File.Rules) | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -205,11 +206,35 @@ func (*gazelleCabalLang) Fix(c *config.Config, f *rule.File) { | |||||
| ruleInfos := cabalToRuleInfos(cabalFiles) | ||||||
|
|
||||||
| for _, r := range f.Rules { | ||||||
| print(r) | ||||||
|
|
||||||
| if !r.ShouldKeep() && | ||||||
| isHaskellRule(r.Kind()) && | ||||||
| !hasRuleInfo(ruleInfos, r.Kind(), r.Name()) { | ||||||
| r.Delete() | ||||||
| } | ||||||
|
|
||||||
| if !r.ShouldKeep() && | ||||||
| r.Kind() == "stack_snapshot" { | ||||||
| print("Case accessed") | ||||||
| var list []string | ||||||
| pack := r.Attr("packages") | ||||||
| switch expr := pack.(type) { | ||||||
|
Member
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. This code is probably better put in a function that extracts an array of strings from an attribute value. |
||||||
| case *bzl.ListExpr: | ||||||
| for _, elem := range expr.List { | ||||||
| switch exprElem := elem.(type) { | ||||||
| case *bzl.StringExpr: | ||||||
| list = append(list, exprElem.Value) | ||||||
| default: | ||||||
| panic("Elements of packages should be string!") | ||||||
|
Member
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.
Suggested change
|
||||||
| } | ||||||
| } | ||||||
| default: | ||||||
| panic("Packages should be a list!") | ||||||
| } | ||||||
| print(list) | ||||||
|
Member
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. There are a few |
||||||
| r.SetAttr("packages", listSortedStringKeys(list)) | ||||||
|
Member
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. Is reordering the strings necessary? If so, perhaps it should be mentioned in the README. |
||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.