Skip to content

Conversation

@yordis
Copy link
Member

@yordis yordis commented Sep 18, 2025

Signed-off-by: Yordis Prieto yordis.prieto@gmail.com

@coderabbitai
Copy link

coderabbitai bot commented Sep 18, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces a package_suffix flag and related logic to generate code into a suffixed sub-package, adjusts output paths/imports accordingly, updates generation conditions, and bumps SupportedEditionsMaximum to 2024. Tests are tightened to assert exact file names and add coverage for go_package_prefix deduplication.

Changes

Cohort / File(s) Summary
Generator logic and flags
cmd/protoc-gen-connect-go-servicestruct/main.go
Added package_suffix flag parsing (via flag.FlagSet/ParamFunc) with default "connect". Updated generate flow to always consider file.Generate, and modified generateFile signature to accept packageSuffix. Validates suffix (go/token), updates Go package name, GeneratedFilenamePrefix, and import paths using path/filepath. Bumped SupportedEditionsMaximum to 2024. Maintains core generation but targets suffixed package when provided.
Tests and path validation
cmd/protoc-gen-connect-go-servicestruct/main_test.go
Strengthened tests to assert exact generated file names. Added TestBufGoPackagePrefixPathGeneration to ensure deduplicated paths with buf go_package_prefix, correct suffixed package declaration, and proper import aliasing.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant protoc as protoc
  participant plugin as protoc-gen-connect-go-servicestruct
  participant flags as FlagSet
  participant gen as generateFile(...)
  participant fs as Output (files)

  protoc->>plugin: Invoke with parameters
  plugin->>flags: Parse package_suffix (default "connect")
  loop For each file
    plugin->>gen: generateFile(plugin, file, packageSuffix)
    alt file has services
      gen->>gen: Validate suffix as Go identifier
      alt suffix invalid
        gen-->>plugin: Emit error, skip file
      else suffix valid or empty
        gen->>gen: Adjust Go package name and import path
        gen->>fs: Create file with suffixed filename/prefix
        gen->>fs: Write header, package decl, imports, service code
      end
    else no services
      gen-->>plugin: Return without file generation
    end
  end
  plugin-->>protoc: Generated files
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

In burrows of code where imports connect,
I twitch my nose at a package suffix check.
Paths deduped neat, no double-hop track,
A tidy new folder on the rabbit’s stack.
With flags in paw and tests exact—thwack!
Hippity-hop, the services are back. 🐇✨

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-1

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 625836b and f31c231.

📒 Files selected for processing (2)
  • cmd/protoc-gen-connect-go-servicestruct/main.go (4 hunks)
  • cmd/protoc-gen-connect-go-servicestruct/main_test.go (3 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yordis yordis force-pushed the fix-1 branch 3 times, most recently from 4bedfb0 to ba3bdb0 Compare September 18, 2025 23:36
@yordis yordis marked this pull request as ready for review September 18, 2025 23:38
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis yordis merged commit cf849b6 into main Sep 18, 2025
2 checks passed
@yordis yordis deleted the fix-1 branch September 18, 2025 23:39
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