Skip to content
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

unused_deps: Add exported dependencies before removing #1169

Merged
merged 2 commits into from
Jul 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions unused_deps/unused_deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ func printCommands(label string, deps map[string]bool) (anyCommandPrinted bool)
if hasRuntimeComment(str) {
fmt.Printf("buildozer 'move deps runtime_deps %s' %s\n", str.Value, label)
} else {
// add dep's exported dependencies to label before removing dep
fmt.Printf("buildozer \"add deps $(%s query 'labels(exports, %s)' | tr '\\n' ' ')\" %s\n", *buildTool, str.Value, label)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to locate a utility function for obtaining a label's attribute but was unable to find one, so I used a bazel query invocation here. It'd be better to avoid the query. I'd appreciate any pointers on this in case I missed something.

fmt.Printf("buildozer 'remove deps %s' %s\n", str.Value, label)
}
anyCommandPrinted = true
Expand Down