Skip to content

Commit

Permalink
Stop moving distribs from a function to the package. (#1223)
Browse files Browse the repository at this point in the history
  • Loading branch information
aiuto authored Jan 23, 2024
1 parent 304e38a commit c224b56
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions edit/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ func movePackageDeclarationToTheTop(f *build.File) bool {
return true
}

// moveToPackage is an auxiliary function used by moveLicensesAndDistribs.
// moveToPackage is an auxiliary function used by moveLicenses.
// The function shouldn't appear more than once in the file (depot cleanup has
// been done).
func moveToPackage(f *build.File, attrname string) bool {
Expand All @@ -461,14 +461,12 @@ func moveToPackage(f *build.File, attrname string) bool {
return fixed
}

// moveLicensesAndDistribs replaces the 'licenses' and 'distribs' functions
// with an attribute in package.
// moveLicenses replaces the 'licenses' function with an attribute
// in package.
// Before: licenses(["notice"])
// After: package(licenses = ["notice"])
func moveLicensesAndDistribs(f *build.File) bool {
fixed1 := moveToPackage(f, "licenses")
fixed2 := moveToPackage(f, "distribs")
return fixed1 || fixed2
func moveLicenses(f *build.File) bool {
return moveToPackage(f, "licenses")
}

// AllRuleFixes is a list of all Buildozer fixes that can be applied on a rule.
Expand Down Expand Up @@ -511,8 +509,6 @@ var FileLevelFixes = []struct {
"Prefer '+=' over 'extend' or 'append'"},
{"unusedLoads", cleanUnusedLoads,
"Remove unused symbols from load statements"},
{"moveLicensesAndDistribs", moveLicensesAndDistribs,
"Move licenses and distribs to the package function"},
}

// FixRule aims to fix errors in BUILD files, remove deprecated features, and
Expand Down

0 comments on commit c224b56

Please sign in to comment.