gladed / gradle-android-git-version

A gradle plugin to calculate Android-friendly version names and codes from git tags
Apache License 2.0
269 stars 30 forks source link

androidGitVersion triggering an exception on a new fork without any tag yet #94

Open anr2me opened 3 months ago

anr2me commented 3 months ago

Tested on a new fork (master branch only and doesn't have any tag yet) of ppsspp repository with ./gradlew androidGitVersion from this PR running the manual_generate_apk.yml https://github.com/ANR2MERefork/ppsspp/actions/runs/8396532920/job/22998104389

Using default execution profile

FAILURE: Build failed with an exception.

* Where:
Build file '/home/runner/work/ppsspp/ppsspp/android/build.gradle' line: 53

* What went wrong:
A problem occurred evaluating project ':android'.
> Not enough room for 39779 in BUILD width=4

* Try:
> Run with --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org./

Where the mentioned build.gradle line 53 is

if (androidGitVersion.name() != "unknown" && androidGitVersion.code() >= 14000000) {

Is there anyway to prevent gradle from crashing? so we can fallback to a default version/naming just like how we handle "unknown", or may be to truncate the code's part to fit the format's part's width so it doesn't crashed (not sure where it get the version code without any tag existed, seems to be a truncated commit hash)

PS: This error only occurred on a new fork

anr2me commented 3 months ago

A workaround to prevent androidGitVersion from crashing when there are no valid tag existed (since a random dummy tag will still crashed), probably by fetching the tags from upstream first.