-
Notifications
You must be signed in to change notification settings - Fork 15
Add contrib v3 migration and update contrib tooling #222
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThe PR introduces a new v3 migration that systematically updates Go Fiber contrib package references from Changes
Sequence DiagramsequenceDiagram
participant User as Calling Code
participant MCP as MigrateContribPackages
participant FCH as ChangeFileContent
participant FS as Filesystem Walk
participant IO as File I/O
User->>MCP: Invoke with cwd
MCP->>FCH: Transform Go imports<br/>(contrib → contrib/v3)
FCH->>FCH: Check hasVersionPrefix<br/>to skip if v3 exists
FCH-->>MCP: Imports updated<br/>(changed flag)
MCP->>FS: Walk directories<br/>for go.mod files
FS->>IO: Read go.mod entries
IO-->>FS: Module lines
FS->>FS: Replace contrib paths<br/>(contrib/... → contrib/v3/...)
FS->>IO: Write updated go.mod
IO-->>FS: Write complete
FS-->>MCP: Walk complete<br/>(changed flag)
alt Any changes made
MCP->>User: Print "Migrating<br/>contrib packages"
else No changes
MCP->>User: No output
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (8)
🧰 Additional context used🧠 Learnings (9)📓 Common learnings📚 Learning: 2024-11-15T07:56:21.623ZApplied to files:
📚 Learning: 2025-10-16T07:19:52.418ZApplied to files:
📚 Learning: 2024-12-13T08:14:22.851ZApplied to files:
📚 Learning: 2024-07-26T21:00:12.902ZApplied to files:
📚 Learning: 2024-10-08T19:06:06.583ZApplied to files:
📚 Learning: 2025-02-12T11:24:31.153ZApplied to files:
📚 Learning: 2024-10-08T19:06:06.583ZApplied to files:
📚 Learning: 2024-11-26T20:05:15.793ZApplied to files:
🧬 Code graph analysis (3)cmd/internal/migrations/v3/contrib_packages_test.go (1)
cmd/internal/migrations/lists.go (1)
cmd/internal/migrations/v3/contrib_packages.go (1)
🔇 Additional comments (15)
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. Comment |
Summary of ChangesHello @ReneWerner87, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces essential updates to the project's migration and tooling infrastructure to support the transition of Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const ( | ||
| contribModulePrefix = "github.com/gofiber/contrib/v3/" | ||
| contribRepoPrefix = "gofiber/contrib/v3" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use correct repo path when generating contrib pseudo versions
The new contribRepoPrefix constant now includes /v3, but refreshContrib passes this value to pseudoVersionFromHash when a hash is provided. pseudoVersionFromHash constructs the GitHub API URL from that prefix, so the request targets https://api.github.com/repos/gofiber/contrib/v3/..., which does not exist—the repository is still gofiber/contrib. As a result, running the contrib refresh command with --hash will fail to fetch commit metadata and cannot compute pseudo versions. Keep the repository prefix as gofiber/contrib while using the /v3 suffix only for import paths.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a migration for gofiber/contrib packages to the v3 module path and updates the related tooling. The changes are well-structured, and the new migration logic is covered by a good set of tests, including checks for idempotency. The updates to the contrib refresh logic and monitor middleware are consistent with the migration. I've found one issue regarding file permission preservation which I've commented on. Overall, this is a solid contribution.
| b, err := os.ReadFile(path) // #nosec G304 -- reading module file | ||
| if err != nil { | ||
| return fmt.Errorf("read %s: %w", path, err) | ||
| } | ||
| content := string(b) | ||
| if !contribModRe.MatchString(content) { | ||
| return nil | ||
| } | ||
| updated := contribModRe.ReplaceAllStringFunc(content, func(match string) string { | ||
| rest := strings.TrimPrefix(match, contribPrefix) | ||
| if rest == match || hasVersionPrefix(rest) { | ||
| return match | ||
| } | ||
| return contribV3Prefix + rest | ||
| }) | ||
| if updated == content { | ||
| return nil | ||
| } | ||
| if err := os.WriteFile(path, []byte(updated), 0o600); err != nil { | ||
| return fmt.Errorf("write %s: %w", path, err) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When updating the go.mod file, the original file permissions are not preserved because os.WriteFile is called with a hardcoded mode 0o600. This could cause unexpected permission changes in the user's project. It's better to read the original file's permissions and use them when writing the updated file.
info, err := d.Info()
if err != nil {
return fmt.Errorf("stat %s: %w", path, err)
}
b, err := os.ReadFile(path) // #nosec G304 -- reading module file
if err != nil {
return fmt.Errorf("read %s: %w", path, err)
}
content := string(b)
if !contribModRe.MatchString(content) {
return nil
}
updated := contribModRe.ReplaceAllStringFunc(content, func(match string) string {
rest := strings.TrimPrefix(match, contribPrefix)
if rest == match || hasVersionPrefix(rest) {
return match
}
return contribV3Prefix + rest
})
if updated == content {
return nil
}
if err := os.WriteFile(path, []byte(updated), info.Mode()); err != nil {
return fmt.Errorf("write %s: %w", path, err)
}
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_6907e5507e1c83269ab613f940ed562c
Summary by CodeRabbit
New Features
Tests