Skip to content

Fix migrate output to show full semver and dedupe migration TODO comments#263

Merged
ReneWerner87 merged 2 commits into
masterfrom
codex/2026-02-02-19-39-28
Feb 3, 2026
Merged

Fix migrate output to show full semver and dedupe migration TODO comments#263
ReneWerner87 merged 2 commits into
masterfrom
codex/2026-02-02-19-39-28

Conversation

@ReneWerner87
Copy link
Copy Markdown
Member

@ReneWerner87 ReneWerner87 commented Feb 2, 2026

Motivation

  • Ensure the fiber migrate output always shows the full semantic version (e.g. 3.0.0) even when the user supplies a short target like -t=3.
  • Avoid producing duplicated // TODO: migrate ... comments when migration logic already emits the same migration TODO as a field name.

Description

  • Normalize parsed target versions to full semver using baseVersion.String() and print the final targetVersion.String() in the migration message in cmd/migrate.go.
  • Add normalizeMigrationComment in cmd/internal/migrations/v3/common.go and call it from FormatFieldWithComment and the unquote error path to suppress duplicate // TODO: migrate comments when the field itself already contains such a marker.
  • Add unit tests: Test_Migrate_TargetVersionShort in cmd/migrate_test.go to cover short -t=3 usage, and TestFormatFieldWithComment_SkipsDuplicateMigrationComment in cmd/internal/migrations/v3/common_test.go to validate comment deduplication.
  • Files changed: cmd/migrate.go, cmd/internal/migrations/v3/common.go, cmd/migrate_test.go, cmd/internal/migrations/v3/common_test.go.

Testing

  • Ran make lint, which completed with 0 issues.
  • Ran make test, which executed the full test suite (307 tests) and completed successfully; new tests passed as part of the run.

Codex Task

Summary by CodeRabbit

  • Bug Fixes

    • Fixed migration messages to display the correct target version.
    • Prevented duplicate migration hints from appearing in field comments by normalizing migration comments.
  • Tests

    • Added test coverage for comment normalization behavior.
    • Added test for short target-version migration path.

@ReneWerner87 ReneWerner87 requested a review from a team as a code owner February 2, 2026 19:39
@ReneWerner87 ReneWerner87 requested review from Copilot, gaby and sixcolors and removed request for a team February 2, 2026 19:39
@ReneWerner87 ReneWerner87 requested a review from efectn February 2, 2026 19:39
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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 enhances the fiber migrate command by improving its output clarity and reducing comment clutter. It ensures that migration messages always present complete semantic versions for better readability and prevents redundant TODO comments from appearing in generated code, streamlining the migration process for developers.

Highlights

  • Full Semantic Versioning in Migration Output: The fiber migrate command now consistently displays the full semantic version (e.g., 3.0.0) in its output, even when a shorthand target (e.g., -t=3) is provided by the user.
  • Deduplication of Migration TODO Comments: Implemented logic to prevent duplicate // TODO: migrate comments. If a field name already contains a migration TODO, the comment associated with it will be suppressed to avoid redundancy.
  • New Unit Tests: Added dedicated unit tests to cover both the short target version handling in cmd/migrate.go and the migration comment deduplication logic in cmd/internal/migrations/v3/common.go.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a 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 effectively addresses its goals of normalizing the version output in fiber migrate and preventing duplicate // TODO: migrate comments. The changes are logical and are accompanied by good tests. I've identified a minor bug in the new comment deduplication logic that occurs in an edge case and have suggested a refactoring to fix it and improve the new function's robustness. I also found a small opportunity to clean up some redundant code. Overall, these are solid improvements to the CLI tool.

Comment thread cmd/internal/migrations/v3/common.go Outdated
Comment thread cmd/migrate.go Outdated
if err != nil {
return fmt.Errorf("invalid version for \"%s\": %w", opts.TargetVersionS, err)
}
opts.TargetVersionS = baseVersion.String()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This line correctly normalizes a short version string (like "3") into a full semver string ("3.0.0"). However, since you've also updated the fmt.Sprintf call on line 184 to use targetVersion.String(), which already holds the full semver, this assignment to opts.TargetVersionS has become redundant for the purpose of display. It's also overwritten later if a hash is provided.

You can safely remove this line to make the code a bit cleaner.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 2, 2026

Walkthrough

Normalize duplicate "TODO: migrate" comments during field formatting, apply the normalization when unquoting fails and when formatting fields, adjust displayed target version to use the parsed version's String(), and add tests for the comment behavior and short target-version handling.

Changes

Cohort / File(s) Summary
Migration comment normalization
cmd/internal/migrations/v3/common.go
Add normalizeMigrationComment(comment string, hasMigrationMarker bool) and call it from replaceFieldImpl (on unquote failure) and FormatFieldWithComment (before appending comment) to skip duplicate "TODO: migrate" comments.
Migration comment tests
cmd/internal/migrations/v3/common_test.go
Add TestFormatFieldWithComment_SkipsDuplicateMigrationComment and import v3 package to verify duplicate migration comment is skipped.
Migration CLI output
cmd/migrate.go
Use targetVersion.String() in final migration message (replacing previous opts.TargetVersionS) and remove an extra blank line.
Migration CLI tests
cmd/migrate_test.go
Add Test_Migrate_TargetVersionShort to exercise short target-version input (e.g., -t=3) and assert expected migration messaging and go.mod update.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

🧹 Updates

Suggested reviewers

  • gaby
  • sixcolors
  • efectn

Poem

🐰 I nibble at comments, tidy and bright,
If "TODO: migrate" mirrors the name, out of sight.
Versions print true, tests hop along,
Clean fields, clean code — a rabbit's small song. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the two main changes: fixing migrate output to show full semver and deduplicating migration TODO comments, matching the core objectives.
Description check ✅ Passed The description comprehensively covers motivation, implementation details, files changed, testing approach, and results, exceeding the template requirements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/2026-02-02-19-39-28

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03dc6ae and c18048d.

📒 Files selected for processing (2)
  • cmd/internal/migrations/v3/common.go
  • cmd/migrate.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build (1.25.x, macos-latest)
🔇 Additional comments (3)
cmd/internal/migrations/v3/common.go (2)

608-614: LGTM!

The logic correctly detects when the field being formatted is already a migration TODO and strips duplicate migration comments from the trailing comment.


616-624: LGTM!

The helper function is straightforward and correctly implements the deduplication logic.

cmd/migrate.go (1)

182-184: LGTM!

Using targetVersion.String() ensures the output always displays the full semver (e.g., 3.0.0 instead of 3), which aligns with the PR objective.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cmd/internal/migrations/v3/common.go (1)

268-276: ⚠️ Potential issue | 🟡 Minor

hasMigrationMarker should likely be true here to deduplicate migration comments.

The replacement being built at line 269 is // TODO: migrate <field>: <val>, which contains a migration marker. If the original comment also contains "TODO: migrate", passing false prevents the duplicate from being stripped.

Compare with line 609 where hasMigrationMarker is true when the output contains the marker. For consistency and to fulfill the PR objective of avoiding duplicate TODO comments, this should be true.

Proposed fix
-			comment = normalizeMigrationComment(comment, false)
+			comment = normalizeMigrationComment(comment, true)
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03dc6ae and c18048d.

📒 Files selected for processing (2)
  • cmd/internal/migrations/v3/common.go
  • cmd/migrate.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build (1.25.x, macos-latest)
🔇 Additional comments (3)
cmd/internal/migrations/v3/common.go (2)

608-614: LGTM!

The logic correctly detects when the field being formatted is already a migration TODO and strips duplicate migration comments from the trailing comment.


616-624: LGTM!

The helper function is straightforward and correctly implements the deduplication logic.

cmd/migrate.go (1)

182-184: LGTM!

Using targetVersion.String() ensures the output always displays the full semver (e.g., 3.0.0 instead of 3), which aligns with the PR objective.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@ReneWerner87 ReneWerner87 added ☢️ Bug Something isn't working 📒 Documentation Improvements or additions to documentation 🤔 Question Further information is requested 🤖 Dependencies Pull requests that update a dependency file and removed 📒 Documentation Improvements or additions to documentation 🤔 Question Further information is requested 🤖 Dependencies Pull requests that update a dependency file labels Feb 3, 2026
@github-actions github-actions Bot added the 📒 Documentation Improvements or additions to documentation label Feb 3, 2026
@ReneWerner87 ReneWerner87 removed the 📒 Documentation Improvements or additions to documentation label Feb 3, 2026
@ReneWerner87 ReneWerner87 merged commit 9e3c119 into master Feb 3, 2026
14 of 24 checks passed
@ReneWerner87 ReneWerner87 deleted the codex/2026-02-02-19-39-28 branch February 3, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ Bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants