sbt / sbt/sbt-git

Multiple labeled tags leads to NumberFormatException during project load

Open
#192 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
355
Forks
104
Avg merge
1d 4h
Merged PRs (30d)
4

Description

In case of multiple tags on HEAD, if any of them is labeled, then a NumberFormatException is thrown and project can't be loaded.

For example, let's say I have v1.0.0 and v1.0.1-alpha, an exception like the one below is thrown:

java.lang.NumberFormatException: For input string: "1-alpha"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.base/java.lang.Integer.parseInt(Integer.java:652)
	at java.base/java.lang.Integer.valueOf(Integer.java:983)
	at versionsort.VersionHelper.compare(VersionHelper.java:32)
	at com.typesafe.sbt.SbtGit$git$.$anonfun$releaseVersion$3(SbtGit.scala:266)
	at com.typesafe.sbt.SbtGit$git$.$anonfun$releaseVersion$3$adapted(SbtGit.scala:266)
	at scala.math.Ordering$$anon$4.compare(Ordering.scala:234)
	at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
	at java.base/java.util.TimSort.sort(TimSort.java:220)
	at java.base/java.util.Arrays.sort(Arrays.java:1441)
	at scala.collection.SeqLike.sorted(SeqLike.scala:659)
	at scala.collection.SeqLike.sorted$(SeqLike.scala:647)
	at scala.collection.AbstractSeq.sorted(Seq.scala:45)
	at scala.collection.SeqLike.sortWith(SeqLike.scala:612)
	at scala.collection.SeqLike.sortWith$(SeqLike.scala:612)
	at scala.collection.AbstractSeq.sortWith(Seq.scala:45)
	at com.typesafe.sbt.SbtGit$git$.releaseVersion(SbtGit.scala:266)
	at com.typesafe.sbt.SbtGit$.$anonfun$versionWithGit$8(SbtGit.scala:196)
	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
	at sbt.internal.util.EvaluateSettings$MixedNode.evaluate0(INode.scala:228)
	at sbt.internal.util.EvaluateSettings$INode.evaluate(INode.scala:170)
	at sbt.internal.util.EvaluateSettings.$anonfun$submitEvaluate$1(INode.scala:87)
	at sbt.internal.util.EvaluateSettings.sbt$internal$util$EvaluateSettings$$run0(INode.scala:99)
	at sbt.internal.util.EvaluateSettings$$anon$3.run(INode.scala:94)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
[error] java.lang.NumberFormatException: For input string: "1-alpha"
[error] Use 'last' for the full log.

From what I could check it's related to https://github.com/sbt/sbt-git/pull/162 and the fact that versionsort.VersionHelper expects tags to strictly follow a pattern like \d(\.\d)+ failing otherwise.

Affected version: 1.0.1.

In order to support projects using different tagging patterns would it be possible to make the tag ordering configurable or disable it altogether?

Ps.: I would be willing to contribute.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at SbtGit.scala around releaseVersion and inspect versionsort.VersionHelper.compare, along with sbt-git pull request 162. Reproduce loading a project with v1.0.0 and v1.0.1-alpha, then determine how configurable ordering or disabling ordering should work. Done means such tags no longer cause NumberFormatException during project load.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, scala
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.