gradle-git-version icon indicating copy to clipboard operation
gradle-git-version copied to clipboard

Make dirty versions SLS-orderable

Open rshkv opened this issue 4 years ago • 3 comments

What happened?

Dirty versions cause errors where version strings are expected to be orderable according to SLS spec.

Caused by: com.palantir.logsafe.exceptions.SafeIllegalArgumentException: Not an orderable version: {value}: {value=1.203.1-8-ge437d05.dirty}
    at com.palantir.logsafe.Preconditions.checkArgument(Preconditions.java:64)
    at com.palantir.sls.versions.OrderableSlsVersion.valueOf(OrderableSlsVersion.java:48)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    ...

Validation is failing in OrderableSlsVersion.java.

What did you want to happen?

Unsure.

  1. Maybe make dirty versions orderable according to SLS (Github), though there's probably not much you can do with the .dirty bit.
  2. Add sth. like gitOrderableVersion() which returns the version without .dirty.

rshkv avatar Mar 02 '20 22:03 rshkv

Oh, I noticed https://github.com/palantir/gradle-git-version/pull/50 and https://github.com/palantir/sls-packaging/pull/202. It looks like sls-packing allows .dirty already, but sls-version-java doesn't.

rshkv avatar Mar 02 '20 22:03 rshkv

I think it a sensible outcome that when an orderable version is required, .dirty is rejected because they are not orderable. We specifically made sls-packaging lenient to avoid this problem. Pasted from the sls-spec:

Non-orderable version strings Version strings follow the non-orderable format if they match the follow regular expression: ^[0-9]+.[0-9]+.[0-9]+(-[a-z0-9-]+)?(.dirty)?$ For example, 1.0.0.dirty, 0.0.1-custom-description-42, and 2.0.0-1-gaaaaaa.dirty are valid but non-orderable version strings, whereas 5.0, 1.1.2.3-foo, 1.1.2.3 and 1.0.0-FOO are not valid version strings under this spec.

There are no ordering guarantees for a pair of non-orderable versions, or between an orderable and a non-orderable version string.

iamdanfox avatar Mar 18 '20 23:03 iamdanfox

I see, if that's the spec that makes sense. Perhaps you'd take a gitVersionClean() that will not add .dirty?

rshkv avatar Jan 13 '21 18:01 rshkv