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

feat: Require correct import path #32

Merged
merged 9 commits into from
Jan 30, 2023
Merged

Conversation

amaury1093
Copy link
Contributor

@amaury1093 amaury1093 commented Jan 25, 2023

Fixes the 2 incorrect registrations:

  • gogo.proto -> gogoproto/gogo.proto
  • descriptor.proto -> google/protobuf/descriptor.proto

cc @testinginprod (can't find you in the reviewers dropdown)

tests are in a separate PR for now: #34

@amaury1093 amaury1093 requested a review from a team as a code owner January 25, 2023 17:36
Comment on lines +794 to +797
expectedPrefix := strings.ReplaceAll(*f.Package, ".", "/") + "/"
if !strings.HasPrefix(*f.Name, expectedPrefix) {
panic(fmt.Errorf("file name %s does not start with expected %s; please make sure your folder structure matches the proto files fully-qualified names", *f.Name, expectedPrefix))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this seems like a good enough check to you?

Copy link
Member

Choose a reason for hiding this comment

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

I think so. @testinginprod what do you think?

Choose a reason for hiding this comment

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

looks correct to me. Should we test it on the sdk?

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 did a branch on the SDK where I pointed to this PR, and it worked

regenerate:
protoc --gogo_out=Mgoogle/protobuf/descriptor.proto=github.com/cosmos/gogoproto/protoc-gen-gogo/descriptor:../../../../ --proto_path=../../../../:../protobuf/:. *.proto
cd .. && protoc --gogo_out=Mgoogle/protobuf/descriptor.proto=github.com/cosmos/gogoproto/protoc-gen-gogo/descriptor:../../../ --proto_path=../../../:./protobuf/:. gogoproto/*.proto
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The fix here is actually just doing some cd so that the OS path matches the FQ name

Choose a reason for hiding this comment

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

correct

Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

utACK

@amaury1093
Copy link
Contributor Author

I'll fix the tests, it seems like the check added in #32 (comment) is shouting on some other (incorrect) import paths.

@amaury1093
Copy link
Contributor Author

amaury1093 commented Jan 25, 2023

There are a lot of failing tests, I'll try to regroup them in one commit (e.g. 97e0165), but it does make the review harder unfortunately... continuing tomorrow.

Copy link
Contributor Author

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

I moved all test fixes into a separate PR: #34. There's 200+ files changed, and I'm not finished yet.

I'll continue working on those tests, but for review's sake I think those should be 2 PRs. We can also merge this one first if that's useful (to unblock v0.47).

Comment on lines +794 to +797
expectedPrefix := strings.ReplaceAll(*f.Package, ".", "/") + "/"
if !strings.HasPrefix(*f.Name, expectedPrefix) {
panic(fmt.Errorf("file name %s does not start with expected %s; please make sure your folder structure matches the proto files fully-qualified names", *f.Name, expectedPrefix))
}
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 did a branch on the SDK where I pointed to this PR, and it worked

Copy link

@testinginprod testinginprod left a comment

Choose a reason for hiding this comment

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

LGTM :)

@amaury1093
Copy link
Contributor Author

If we are okay to merge with failing tests for now, then can an admin do it?

I'll fix the tests in #34

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.

4 participants