ajoberstar / reckon

Infer a project's version from your Git repository.
Apache License 2.0
187 stars 28 forks source link

Do not sort stages alphabetically to find the default stage #103

Closed Townk closed 5 years ago

Townk commented 5 years ago

Could you remove this line from reckon-core?

https://github.com/ajoberstar/reckon/blob/610be9d86c90c79b5271517fc4c756809f359f19/reckon-core/src/main/java/org/ajoberstar/reckon/core/Reckoner.java#L200

This way, the order that I define my stages is the order that the plugin will consider. For instance, in my case I have:

    stageFromProp("nightly", "beta", "final")

A beta version is only released after several nightly ones. But with the plugin the way it is, the beta version is used as the default version.

ajoberstar commented 5 years ago

I'm going to close this as a won't fix. SemVer very specifically defines precedence (point 11 in the spec) of pre-release components as ASCII sort order. It may not be ideal in all circumstances, but it's a clear way to do sorting. Since SemVer is core to how Reckon works, this behavior is going to stay as-is.

Townk commented 5 years ago

Thanks for the reply. So, let me double check on the behavior of the plugin then:

If I define the following stages:

  stageFromProp("gamma", "zetta", "final")

The default stage will be final, correct?

ajoberstar commented 5 years ago

It would be gamma. Final is ignored when picking a default.

Townk commented 5 years ago

Wouldn't that break the rule of following SemVer? I read the specification and there is nothing mentioning the "final" stage being anything special.

One alternative would be to create an option on the Reckon extension called strictSemVer. It is set to true by default and when it is, the SemVer specification would be followed very strictly (e.g. on my previous example, the default stage would be final and the last stage would be zetta). If the user sets this property to false, then we could use the order of the defined props as I asked for in the first place.

What do you think about that?

ajoberstar commented 5 years ago

final is more of a logical stage. It means we won't add any pre-release info to the version (i.e. final isn't in the resulting version string).

SemVer dependent logic is heavily embedded into reckon's code and its purpose. I'm not interested in making it optional, which would add a bunch of maintenance complexity.

Townk commented 5 years ago

Fair enough.

sschuberth commented 5 years ago

What's even more confusing IMO is that depending on the command used, there is a default for the stage or not. This example shows that "beta" is considered the default stage when running ./gradlew build. However, running e.g. ./gradlew reckonTagCreate does not seem to be using any default stage, and even worse, the build succeeds without the tag being created. You have to explicitly use ./gradlew reckonTagCreate -Preckon.stage=beta to create the tag with the expected version.

ajoberstar commented 5 years ago

That's more an issue with the documentation being unclear about what "default" means. It makes it sound like you don't need to specify reckon.stage because it will default to something, but what I really meant is that if you don't provide a stage an insignificant (see README) will be created. Insignificant versions still have a stage in the resulting version, and it will either be the same as the last tagged version (e.g. if you released 1.0.0-rc.1, the insignificant would be something like 1.0.0-rc.1.4+abcde1234) or it will fallback to the first stage in sort order (i.e. the default).