-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Ensure repository names don't start with ~
#16564
Ensure repository names don't start with ~
#16564
Conversation
f943c03
to
a66e356
Compare
~
~
} else { | ||
nonEmptyRepoPart = repoName; | ||
} | ||
String bestName = nonEmptyRepoPart + "~" + id.getExtensionName(); |
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.
Nit: Maybe we also check if id.getExtensionName()
is empty? It probably should be done early: https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleFileGlobals.java;l=407
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.
It's not strictly necessary since a path ending but not starting with a tilde should not require escaping.
Wouldn't an empty extensionName
already lead to an error since it needs to name a Starlark export in the file and these cannot have empty names?
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.
Ah, that make sense.
// not start with a tilde. | ||
String repoName = id.getBzlFileLabel().getRepository().getName(); | ||
String nonEmptyRepoPart; | ||
if (repoName.isEmpty()) { |
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.
Nit: maybe id.getBzlFileLabel().getRepository().isMain()
is a bit more clear? Since other Bazel modules should have a non-empty repo name
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.
Changed
a66e356
to
445de0b
Compare
} else { | ||
nonEmptyRepoPart = repoName; | ||
} | ||
String bestName = nonEmptyRepoPart + "~" + id.getExtensionName(); |
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.
Ah, that make sense.
@bazel-io flag |
@bazel-io fork 6.0.0 |
By ensuring that repository names do not start with `~`, runfiles paths are certain not to begin with tildes, which means that they don't need to be shell escaped. Prevents bazelbuild#16560 (comment) Closes bazelbuild#16564. PiperOrigin-RevId: 484232215 Change-Id: Ie70940aa709f6c7a886564189a3579780731dca6
By ensuring that repository names do not start with `~`, runfiles paths are certain not to begin with tildes, which means that they don't need to be shell escaped. Prevents #16560 (comment) Closes #16564. PiperOrigin-RevId: 484232215 Change-Id: Ie70940aa709f6c7a886564189a3579780731dca6
By ensuring that repository names do not start with
~
, runfiles paths are certain not to begin with tildes, which means that they don't need to be shell escaped.Prevents #16560 (comment)