neoforged / GradleUtils

Gradle buildscript utility library for NeoForged projects
GNU Lesser General Public License v2.1
1 stars 5 forks source link

GradleUtils doesn't handle no available tags gracefully #10

Closed Nightenom closed 8 months ago

Nightenom commented 9 months ago
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.List.size()" because "self" is null
    at net.neoforged.gradleutils.VersionCalculator.findTag(VersionCalculator.groovy:85)
    at net.neoforged.gradleutils.VersionCalculator.calculate(VersionCalculator.groovy:35)
    at net.neoforged.gradleutils.VersionCalculator.calculate(VersionCalculator.groovy)
    at net.neoforged.gradleutils.VersionCalculatorValueSource.obtain(VersionCalculatorValueSource.groovy:35)
    at net.neoforged.gradleutils.VersionCalculatorValueSource.obtain(VersionCalculatorValueSource.groovy)
    at org.gradle.internal.Try.ofFailable(Try.java:41)
    at org.gradle.api.internal.provider.DefaultValueSourceProviderFactory$LazilyObtainedValue.obtain(DefaultValueSourceProviderFactory.java:301)
    at org.gradle.api.internal.provider.DefaultValueSourceProviderFactory$ValueSourceProvider.calculateOwnValue(DefaultValueSourceProviderFactory.java:256)
    at org.gradle.api.internal.provider.AbstractMinimalProvider.calculateOwnPresentValue(AbstractMinimalProvider.java:80)
    at org.gradle.api.internal.provider.AbstractMinimalProvider.get(AbstractMinimalProvider.java:100)
    at net.neoforged.gradleutils.GradleUtilsExtension$1.toString(GradleUtilsExtension.groovy:80)
    at net.neoforged.gradleutils.GradleUtilsExtension$1$toString.call(Unknown Source)
    at build_1rpfzhdnjltyux4db49sft535.run(P:\data\github\NeoGradle\build.gradle:8)
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
    ... 175 more
sciwhiz12 commented 9 months ago

GradleUtils 3 currently doesn't gracefully handle the situation of there being no tags.

https://github.com/neoforged/GradleUtils/blob/74ecb4ec23c808aa704e5a1ef959ece85b1af89d/src/main/groovy/net/neoforged/gradleutils/VersionCalculator.groovy#L81-L85

The describe call doesn't require a value to always be given (where it would give a commit hash in lieu of a tag-describe output), which means it returns null.