Skip to content

feat: Require correct import path#32

Merged
tac0turtle merged 9 commits intomainfrom
am/correct-import-path
Jan 30, 2023
Merged

feat: Require correct import path#32
tac0turtle merged 9 commits intomainfrom
am/correct-import-path

Conversation

@amaury1093
Copy link
Copy Markdown
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 review from a team and aaronc 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
Copy Markdown
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
Copy Markdown
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?

Copy link
Copy Markdown

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
Copy Markdown
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

# ref: https://github.com/cosmos/cosmos-sdk/issues/14713
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
Copy Markdown
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

correct

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@amaury1093 amaury1093 force-pushed the am/correct-import-path branch from 165f930 to 97e0165 Compare January 25, 2023 18:39
@amaury1093 amaury1093 force-pushed the am/correct-import-path branch from b582d8b to 5ee00ef Compare January 26, 2023 15:17
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown

@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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

4 participants