Skip to content
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

semver spec violation for versions with build metadata #18

Closed
mwarren opened this issue Mar 4, 2015 · 5 comments

Comments

@mwarren
Copy link

commented Mar 4, 2015

According to semver 2.0.0, spec rule number 10, two versions that differ only in build metadata should have the same precedence. However, cmp of two such versions returns non-zero:

$ python
Python 2.7.6 (default, Sep  9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from semantic_version import Version
>>> cmp(Version('1.0.0'), Version('1.0.0+build'))
-1

I almost started working on a fix and pull request, but it looks from pydoc in the code that this might be intentional?

@Shir0kamii

This comment has been minimized.

Copy link

commented Sep 8, 2015

I think i would be better to fix it, should it have been intentional or not. What are your opinion @rbarrois ?

@mwarren

This comment has been minimized.

Copy link
Author

commented Sep 11, 2015

Sorry, I linked to the wrong bit of code. Relevant code is in the build_cmp function.

rbarrois added a commit that referenced this issue Sep 15, 2015

Forbid build metadata ordering (See #18)
SemVer 2.0.0 states that "Build metadata SHOULD be ignored when
determining version precedence".

This means that, when comparing ``0.1.0+1`` to ``0.1.0+bcd``::

    >>> Version('0.1.0+1') == Version('0.1.0+bcd')
    False
    >>> Version('0.1.0+1') != Version('0.1.0+bcd')
    True
    >>> Version('0.1.0+1') < Version('0.1.0+bcd')
    False
    >>> Version('0.1.0+1') > Version('0.1.0+bcd')
    False
    >>> Version('0.1.0+1') <= Version('0.1.0+bcd')
    False
    >>> Version('0.1.0+1') >= Version('0.1.0+bcd')
    False
    >>> compare(Version('0.1.0+1'), Version('0.1.0+bcd'))
    NotImplemented

This change also has the following effects:
- When including build metadata in a ``Spec``, the only valid options
  are ``Spec('==0.1.0+sth')`` and ``Spec('!=0.1.0+sth')``
- The meaning of ``Spec('==0.1.0+')`` is now "Only version 0.1.0 without
  build metadata"
- ``Spec('==0.1.0')`` now matches ``Version('0.1.0+anything')``
@rbarrois

This comment has been minimized.

Copy link
Owner

commented Sep 15, 2015

Well, that's an interesting problem.
The only goal of that feature was to state that versions without build metadata take precedence over versions with metadata.

After reading some issues on the main SemVer repo, a release might include build metadata; this means that my assumptions were broken here.

I have just updated the code relating to that suggestion; this brings many changes.

@Shir0kamii

This comment has been minimized.

Copy link

commented Sep 16, 2015

Thank you for taking care of this !

Please don't forget to upload the new version on Pypi. It'll be helpful for people using it in other projects.

@rbarrois

This comment has been minimized.

Copy link
Owner

commented Feb 12, 2016

Going out in the upcoming release :)

Thanks everybody for the help!!

@rbarrois rbarrois closed this Feb 12, 2016

clrpackages pushed a commit to clearlinux-pkgs/semantic_version that referenced this issue Jul 12, 2016

Alberto Murillo clrbuilder
semantic_version: Autospec creation for update from version 2.4.2 to …
…version 2.5.0

ChangeLog
=========

2.5.0 (2016-02-12)
------------------

*Bugfix:*

    `#18 <https://github.com/rbarrois/python-semanticversion/issues/18>`_: According to SemVer 2.0.0, build numbers aren't ordered.

    * Remove specs of the ``Spec('<1.1.3+')`` form
    * Comparing ``Version('0.1.0')`` to ``Version('0.1.0+bcd')`` has new
      rules::

          >>> Version('0.1.0+1') == Version('0.1.0+bcd')

clrpackages pushed a commit to clearlinux-pkgs/semantic_version that referenced this issue Oct 18, 2016

Alberto Murillo clrbuilder
semantic_version: Autospec creation for update from version 2.4.2 to …
…version 2.5.0

ChangeLog
=========

2.5.0 (2016-02-12)
------------------

*Bugfix:*

    `#18 <https://github.com/rbarrois/python-semanticversion/issues/18>`_: According to SemVer 2.0.0, build numbers aren't ordered.

    * Remove specs of the ``Spec('<1.1.3+')`` form
    * Comparing ``Version('0.1.0')`` to ``Version('0.1.0+bcd')`` has new
      rules::

          >>> Version('0.1.0+1') == Version('0.1.0+bcd')

clrpackages pushed a commit to clearlinux-pkgs/semantic_version that referenced this issue Jan 11, 2017

Alberto Murillo clrbuilder
semantic_version: Autospec creation for update from version 2.4.2 to …
…version 2.5.0

ChangeLog
=========

2.5.0 (2016-02-12)
------------------

*Bugfix:*

    `#18 <https://github.com/rbarrois/python-semanticversion/issues/18>`_: According to SemVer 2.0.0, build numbers aren't ordered.

    * Remove specs of the ``Spec('<1.1.3+')`` form
    * Comparing ``Version('0.1.0')`` to ``Version('0.1.0+bcd')`` has new
      rules::

          >>> Version('0.1.0+1') == Version('0.1.0+bcd')

clrpackages pushed a commit to clearlinux-pkgs/semantic_version that referenced this issue Jan 17, 2017

Alberto Murillo clrbuilder
semantic_version: Autospec creation for update from version 2.4.2 to …
…version 2.5.0

ChangeLog
=========

2.5.0 (2016-02-12)
------------------

*Bugfix:*

    `#18 <https://github.com/rbarrois/python-semanticversion/issues/18>`_: According to SemVer 2.0.0, build numbers aren't ordered.

    * Remove specs of the ``Spec('<1.1.3+')`` form
    * Comparing ``Version('0.1.0')`` to ``Version('0.1.0+bcd')`` has new
      rules::

          >>> Version('0.1.0+1') == Version('0.1.0+bcd')

clrpackages pushed a commit to clearlinux-pkgs/semantic_version that referenced this issue May 5, 2017

Alberto Murillo clrbuilder
semantic_version: Autospec creation for update from version 2.4.2 to …
…version 2.5.0

ChangeLog
=========

2.5.0 (2016-02-12)
------------------

*Bugfix:*

    `#18 <https://github.com/rbarrois/python-semanticversion/issues/18>`_: According to SemVer 2.0.0, build numbers aren't ordered.

    * Remove specs of the ``Spec('<1.1.3+')`` form
    * Comparing ``Version('0.1.0')`` to ``Version('0.1.0+bcd')`` has new
      rules::

          >>> Version('0.1.0+1') == Version('0.1.0+bcd')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.