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

Allow setting proto_strip_import_prefix from root BUILD.bazel #977

Merged
merged 2 commits into from Jan 6, 2021

Conversation

linzhp
Copy link
Contributor

@linzhp linzhp commented Dec 31, 2020

What type of PR is this?
Bug fix

What package or component does this PR mostly affect?

language/proto

What does this PR do? Why is it needed?
In go_repository rules, all Gazelle directives are at the root level BUILD.bazel. We should allow setting proto_strip_import_prefix at the root BUILD.bazel without warnings

@achew22
Copy link
Member

achew22 commented Dec 31, 2020

@linzhp not a maintainer of Gazelle, but you might consider adding some tests to demonstrate the old broken behavior and ensure that there are no regressions.

Copy link
Contributor

@jayconrod jayconrod left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for fixing this.

@@ -282,7 +282,7 @@ func checkStripImportPrefix(prefix, rel string) error {
if !strings.HasPrefix(prefix, "/") {
return fmt.Errorf("proto_strip_import_prefix should start with '/' for a prefix relative to the repository root")
}
if !pathtools.HasPrefix(rel, prefix[1:]) {
if rel != "" && !pathtools.HasPrefix(rel, prefix[1:]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this ends up being repeated anywhere else, it might make sense for pathtools.HasPrefix and TrimPrefix to support empty paths.

@jayconrod jayconrod merged commit 1f65a18 into bazelbuild:master Jan 6, 2021
@linzhp linzhp deleted the proto_strip branch January 6, 2021 21:59
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

3 participants