Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Enhancement: Allow bumping Version #13

Merged
merged 1 commit into from
Dec 25, 2023
Merged

Enhancement: Allow bumping Version #13

merged 1 commit into from
Dec 25, 2023

Conversation

localheinz
Copy link
Member

This pull request

  • allows bumping a Version

Fixes #7.

Copy link

codecov bot commented Dec 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8dcfba2) 98.48% compared to head (728af47) 98.64%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #13      +/-   ##
============================================
+ Coverage     98.48%   98.64%   +0.16%     
- Complexity       68       71       +3     
============================================
  Files            13       13              
  Lines           198      222      +24     
============================================
+ Hits            195      219      +24     
  Misses            3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

'10.20.30' => '11.0.0',
'1.1.2-prerelease+meta' => '2.0.0',
'1.1.2+meta' => '2.0.0',
'1.0.0-alpha' => '2.0.0',
Copy link
Member Author

Choose a reason for hiding this comment

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

Not entirely sure whether this makes sense, see https://semver.org/#spec-item-11.

@localheinz localheinz merged commit bc2cdc9 into main Dec 25, 2023
@localheinz localheinz deleted the feature/bump branch December 25, 2023 16:45
@dsentker
Copy link

dsentker commented Dec 25, 2023

@localheinz Oops, you were faster than me. I think your solution is more elegant.

My idea was to provide an update() method to overwrite specific parts of the version string.

Let's keep your implementation :-)

private function update(
        ?Major $major = null,
        ?Minor $minor = null,
        ?Patch $patch = null,
        ?PreRelease $preRelease = null,
        ?BuildMetaData $buildMetaData = null,
    ): self {
        $newMajor = $major ?? $this->major;
        $newMinor = $minor ?? $this->minor;
        $newPatch = $patch ?? $this->patch;
        $newPreRelease = $preRelease ?? $this->preRelease;
        $newBuildMetaData = $buildMetaData ?? $this->buildMetaData;

        $newVersionString = \sprintf(
            '%d.%d.%d-%s+%s',
            $newMajor->toInt(),
            $newMinor->toInt(),
            $newPatch->toInt(),
            $newPreRelease->toString(),
            $newBuildMetaData->toString(),
        );

        $newVersionString = \rtrim($newVersionString, '+'); // Strip build metadata character if empty
        $newVersionString = \rtrim($newVersionString, '-'); // Strip prerelease character if empty

        return self::fromString($newVersionString);
    }

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide method(s) for version bump
3 participants