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

buildozer: correctly substitute custom string attrs #1246

Merged

Conversation

thumphries-stripe
Copy link
Contributor

  • Fix a bug in the substitute buildozer command
  • Add some tests for that command, since none were found

getAttrValueExpr runs via the TypeOf map, and encodes the value as an ident if the type is not known. This works correctly for known attributes, but produces an invalid result for anything not contained in that map.

However, we already know the attribute is a string due to the type assertion on L543, and can construct it directly.

Copy link

google-cla bot commented Mar 1, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Comment on lines +436 to +441
{
name: "custom_attr",
args: []string{"*", "^//(.*)$", "//foo/${1}"},
buildFile: `cc_library(my_custom_attr = "//bar/baz:quux")`,
expected: `cc_library(my_custom_attr = "//foo/bar/baz:quux")`,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test case covers the bug in question, the others are included just for fun.

I confirmed the test fails if my change is reverted.

Copy link
Member

@vladmos vladmos left a comment

Choose a reason for hiding this comment

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

Thanks!

@vladmos vladmos merged commit 2bc4b5e into bazelbuild:master Apr 17, 2024
2 checks passed
apattidb pushed a commit to databricks/buildtools that referenced this pull request May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants