jib icon indicating copy to clipboard operation
jib copied to clipboard

Fix version comparison logic in update checker

Open Gautam-aman opened this issue 3 weeks ago • 3 comments

Summary

This PR fixes the issue where the update check incorrectly reports an older version as a newer one. For example, it reported 3.4.6 as newer even when the currently used version was 3.5.0.

Root Cause

Version strings were compared lexicographically instead of numerically (e.g., "3.10" < "3.9" when using string comparison).

Fix

  • Implemented numeric comparison for version segments.
  • Treated shorter version strings (3.5) as equivalent to 3.5.0.
  • Added comprehensive unit test testCompareVersions() to prevent regressions.

Tests

All tests pass: ./gradlew :jib-plugins-common:test ./gradlew :jib-maven-plugin:test

This resolves the incorrect user warning which caused confusion as 3.4.6 is older than 3.5.0.

Notes

No behavior changes other than correcting version comparison.

Gautam-aman avatar Dec 07 '25 17:12 Gautam-aman

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Dec 07 '25 17:12 google-cla[bot]

Summary of Changes

Hello @Gautam-aman, I'm Gemini Code Assist[^1]! 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 addresses a critical bug in the update checker that caused it to misidentify older versions as newer, resulting in erroneous update prompts. The change introduces a sophisticated numeric version comparison mechanism, ensuring that update notifications are accurate and only triggered for genuinely newer versions. This enhancement improves the reliability of the update checker without altering any other system behaviors.

Highlights

  • Fixes Incorrect Update Reporting: The pull request resolves an issue where the update checker would incorrectly report an older version as a newer one, leading to misleading update notifications.
  • Numeric Version Comparison: The core of the fix involves replacing lexicographical string comparison of version numbers with a robust numeric comparison logic. This correctly handles cases like '3.10' being greater than '3.9'.
  • Handles Shorter Version Strings: The new comparison logic correctly treats shorter version strings (e.g., '3.5') as equivalent to their longer counterparts (e.g., '3.5.0') for accurate comparison.
  • Comprehensive Unit Tests: A new unit test, testCompareVersions(), has been added to validate the new version comparison logic against various scenarios, ensuring the fix is robust and prevents future regressions.
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 :thumbsup: and :thumbsdown: 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.

[^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.

gemini-code-assist[bot] avatar Dec 07 '25 17:12 gemini-code-assist[bot]

Thanks for the helpful review! 🙌 I've updated the PR to:

  • Handle prerelease suffixes such as -SNAPSHOT, -alpha, -beta
  • Add test coverage for these cases
  • Switch to a manual numeric-prefix parser to avoid regex overhead

Please let me know if you'd like any further improvements.

Gautam-aman avatar Dec 07 '25 17:12 Gautam-aman