Skip to content

feat: Improve Semver support#80

Merged
immortius merged 1 commit intodevelopfrom
topic/semver-improvements
Jun 20, 2020
Merged

feat: Improve Semver support#80
immortius merged 1 commit intodevelopfrom
topic/semver-improvements

Conversation

@skaldarnar
Copy link
Member

@skaldarnar skaldarnar commented Jun 10, 2020

This is an attempt to improve the compatibility with Semver v2 as
defined by https://semver.org/ by introducing jsemver as internal
representation for the Version class.

Note that these changes lead to slightly different behavior in the
increment methods. Previously, the respective version level would be
increased while setting all less important numbers (to the right) to
zero. For instance

new Version("1.2.0-SNAPSHOT").getNextMinorVersion()   // 1.3.0

With basing the internal representation on jsemver this changed to

new Version("1.2.0-SNAPSHO").getNextMinorVersion()    // 1.2.0

Similar different behavior can be observed for the other parts.

With jsemver as internal representation we could easily support more of
Semver specification in gestalt by exposing both the full prerelease
information and the build metadata.
I'd also like to offer methods for version increments which will
directly set the prerelease information, like

version.getNextMinorVersion("SNAPSHOT")

This would be helpful for implementing CLI tooling in Terasology to
easily prepare a specific release and switch to the next snapshot
version.

Please feel free to share suggestions or opinions on this. I was also
considering to implement the Semver specification from scratch or
whether we should fork the whole project...

This is an attempt to improve the compatibility with Semver v2 as
defined by https://semver.org/ by introducing **jsemver** as internal
representation for the Version class.

Note that these changes lead to slightly different behavior in the
increment methods. Previously, the respective version level would be
increased while setting all less important numbers (to the right) to
zero. For instance

```java
new Version("1.2.0-SNAPSHOT").getNextMinorVersion()   // 1.3.0
```

With basing the internal representation on jsemver this changed to

```java
new Version("1.2.0-SNAPSHO").getNextMinorVersion()    // 1.2.0
```

Similar different behavior can be observed for the other parts.

With jsemver as internal representation we could easily support more of
Semver specification in _gestalt_ by exposing both the full _prerelease_
information and the _build metadata_.
I'd also like to offer methods for version increments which will
directly set the prerelease information, like

```java
version.getNextMinorVersion("SNAPSHOT")
```

This would be helpful for implementing CLI tooling in Terasology to
easily prepare a specific release and switch to the next snapshot
version.

Please feel free to share suggestions or opinions on this. I was also
considering to implement the Semver specification from scratch or
whether we should fork the whole project...
@skaldarnar skaldarnar requested review from immortius and keturn June 10, 2020 22:27
@skaldarnar skaldarnar added Type: Improvement Request for or addition/enhancement of a feature Topic: Module Requests, Issues and Changes related to gestalt modules labels Jun 10, 2020
@immortius immortius merged commit 548c921 into develop Jun 20, 2020
@immortius
Copy link
Member

Looks good, I would be happy to have further functionality exposed. I guess the state of the jsemver library is something we'll have to keep an eye on - as it hasn't had its first major version release yet, nor is it in maven central (also a problem for gestalt, which I would like to address one day).

@Cervator Cervator deleted the topic/semver-improvements branch June 20, 2020 15:04
@skaldarnar
Copy link
Member Author

[...] as it hasn't had its first major version release yet, nor is it in maven central

Agreed on both. In worst case we'll have to add gestalt-semver and maintain it ourselves 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Topic: Module Requests, Issues and Changes related to gestalt modules Type: Improvement Request for or addition/enhancement of a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants