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

Update most of Go native lang to be repoless #459

Merged
merged 1 commit into from
Sep 23, 2024
Merged

Conversation

DavidSGK
Copy link
Member

@DavidSGK DavidSGK commented Sep 23, 2024

We want to reduce dependencies when syncing/gen'ing for native lang. Similar to lekkodev/ts-tools#45, the changes here make things (mostly) repoless for Go.

Changes are messy and a bit hard to follow, but these are the general details:

  • Updated deps to use new repository contents types from Add Namespace and RepositoryContents messages in feature package #458
  • Updated syncer to output repository contents instead of only writing to local config repository
  • Updated generator to be constructed from repository contents instead of only reading from local config repository
  • Added utility functions for reading/writing repository contents from/to a local config repository
  • Update existing Go gen/sync tests
  • etc.

There's still some work left after this PR, but this felt like a sane pausing point after the critical Go-related changes:

  • Updating TS generator to use repository contents
  • Updating gen/sync/bisync commands to have clear controls on whether local repository is involved or not
    • As a followup, updating push/pull based on how we want those to behave with these changes
  • Cleanup on constructor/function signatures that are a bit all over the place at the moment
  • Cleaning up unused functions that were used for testing or outdated commands

@DavidSGK DavidSGK self-assigned this Sep 23, 2024
func NewDefaultFileDescriptorSet() *descriptorpb.FileDescriptorSet {
fds := &descriptorpb.FileDescriptorSet{}
fds.File = append(fds.File, protodesc.ToFileDescriptorProto(descriptorpb.File_google_protobuf_descriptor_proto))
Copy link
Member Author

Choose a reason for hiding this comment

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

I needed to also add this file descriptor, otherwise the descriptors added in #453 break sync because they depend on it

Comment on lines +146 to +147
// Test code -> repo -> code (compare) -> repo (compare)
func TestGoSyncToGenToSync(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This replaces the removed test methods by running through all of the test cases but also adding an extra sync step to compare parsed repository contents.

Comment on lines +180 to +182
type goSyncer struct {
fset *token.FileSet
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Syncer struct was simplified a lot since we no longer need a repository and start from a blank file descriptor set. It was also changed to be repo-based rather than namespace-based because the FDS is shared and needs to be updated across namespaces. This is why a bunch of methods now take an additional namespace arg.

@DavidSGK DavidSGK changed the title Update most of Go native lang to repoless Update most of Go native lang to be repoless Sep 23, 2024
@DavidSGK DavidSGK marked this pull request as ready for review September 23, 2024 22:01
@DavidSGK DavidSGK merged commit 0f9a3fd into main Sep 23, 2024
1 check passed
@DavidSGK DavidSGK deleted the david/go-repoless-sync branch September 23, 2024 23:45
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.

2 participants