← 输入框|github.com|刷新
Skip to content

Unable to create pre-release with an empty token #344

Closed

Description

@vincent-herlemont

Situation

Unable to create pre-release with an empty token.

To Reproduce

Run this script:

ver = semver.VersionInfo.parse('1.0.0')
ver = ver.bump_prerelease('');
print(ver)
# 1.0.0-rc.1

Expected Behavior

.bump_prerelease('') should generate an version like 1.0.0-1.

Environment

  • OS: Linux ubuntu 5.11.0-40-generic
  • Python version: Docker image python:3.8
  • Version of semver library: semver==2.13.0

Additional context

Pre-release documentation https://semver.org/#spec-item-9

Activity

  1. added
    Bug
    on Nov 30, 2021
  2. tomschr commented on Dec 7, 2021

    @tomschr
    Member

    Thank you @vincent-herlemont, much appreciated. Sorry for the late response.

    I suppose, this should be fixed. This behaviour is the same for the method .bump_build(). So both need to be adapted.

  3. tomschr commented on Oct 8, 2022

    @tomschr
    Member

    @vincent-herlemont One question. What would you expect if you have already a prerelease and pass an empty string? Like this:

    >>> ver = semver.VersionInfo.parse('1.0.0-rc.1')
    >>> ver.bump_prerelease('')
    # ???
    

    I could think of two solutions:

    1. Basically ignore the token argument in .bump_prerelease(). In our case above, you would get 1.0.0-rc.2.
    2. Overwrite with the token argument in .bump_prerelease(). In our case above, you would get 1.0.0-0.

    If you already have a prerelease, you would like to continue when using .bump_prerelease(), right? Solution 2 would be more flexible.

    In other words: If prerelease isn't set, the token is taken into account, otherwise it's ignored (regardless of the value).

  4. added a commit that references this issue on Oct 8, 2022
    496e81f
  5. added 2 commits that reference this issue on Dec 18, 2022
    6e8231c
    4b30940
  6. added a commit that references this issue on Feb 20, 2023
    cc5d01f
  7. added 6 commits that reference this issue on Mar 5, 2023
    011f680
    c5e732b
    f7cbf24
    cecbe8a
    b1a01cd
    f8a182f
  8. added a commit that references this issue on Mar 5, 2023
    a2a6169
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug

    Type

    No type

    Fields

    SIze

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions