Skip to content

Conversation

@G-Rath
Copy link
Collaborator

@G-Rath G-Rath commented Aug 19, 2025

Currently we're not correctly handling versions with build strings, as the semver spec does not specify how they should be compared so we consider them equal but Pub compares them lexicographically

@G-Rath
Copy link
Collaborator Author

G-Rath commented Aug 19, 2025

I have tested this in https://dartpad.dev/ with:

import 'package:pub_semver/pub_semver.dart';

void main() {
  for (var [a, b] in [
    ['1.0.0', '1.0.0'],
    ['1.0.0-pre', '1.0.0-pre+build'],
    ['1.0.0-pre+build', '1.0.0'],
    ['1.0.0', '1.0.0+build'],
    ['1.2.3+1', '1.2.3+2'],
    ['1.2.3+1', '1.2.3+a'],
    ['1.2.3+9', '1.2.3+a'],
    ['1.2.3+900', '1.2.3+a'],
    ['1.2.3+a1', '1.2.3+a'],
    ['1.2.3+a1', '1.2.3+a1'],
    ['1.2.3+a1', '1.2.3+a2'],
    ['1.2.3+a', '1.2.3+b'],
    ['1.2.3+a9', '1.2.3+b2'],
    ['1.2.3+9a', '1.2.3+1z'],

    // ---
    ['1.2.3-r100', '1.2.3-R2'],
    ['1.2.3-beta+build', '1.2.3-beta+otherbuild'],
  ]) {
    print(Version.parse(a).compareTo(Version.parse(b)));
  }
}

@copybara-service copybara-service bot merged commit 30c71f6 into google:main Aug 26, 2025
12 checks passed
@G-Rath G-Rath deleted the semantic/support-pub-properly branch August 26, 2025 23:04
another-rex pushed a commit to ossf/osv-schema that referenced this pull request Aug 27, 2025
Among other things this includes
google/osv-scalibr#1196 which will unblock #407

Signed-off-by: Gareth Jones <3151613+G-Rath@users.noreply.github.com>
jess-lowe pushed a commit to jess-lowe/osv-schema that referenced this pull request Sep 15, 2025
Among other things this includes
google/osv-scalibr#1196 which will unblock ossf#407

Signed-off-by: Gareth Jones <3151613+G-Rath@users.noreply.github.com>
Signed-off-by: Jess Lowe <jesslowe@google.com>
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.

3 participants