Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynVer.isSnapshot is wrong when no tagPrefix is used #294

Open
SuperFola opened this issue Jul 2, 2024 · 0 comments
Open

DynVer.isSnapshot is wrong when no tagPrefix is used #294

SuperFola opened this issue Jul 2, 2024 · 0 comments

Comments

@SuperFola
Copy link

We have a use case where we do not use the tag prefix (our projects are tagged like 4.1.2, 12.0.0...), and make use of DynVer.isSnapshot to determine where we want to publish projects.

ThisBuild / publishTo := {
  val nexus: String = "https://nexus.example.net/repository/my-repository"
  val a = if (DynVer.isSnapshot())
    Some("Sonatype Nexus Repository Manager" at nexus + "-dev-snapshot")
  else {
    Some("Sonatype Nexus Repository Manager" at nexus + "-release")
  }

  a match {
    case Some(v) => streams.value.log.log(Level.Info, s">>> ${v.toString()} hasNoTag:${DynVer.hasNoTags()} isDirty:${DynVer.isDirty()} ${DynVer.tagPrefix}")
  }

  a
}

However in this example we always log the dev-snapshot repository, because hasNoTag is always true, because it is implemented as follows:

def hasNoTags(): Boolean = !ref.isTag

And isTag is based on the prefix (which we do not use, we have set ThisBuild / dynverVTagPrefix := false:

def isTag: Boolean     = value.startsWith(prefix)

I think it would be better to make use of inheritance on GitRef, so that a proper isTag could be implemented for GitCommit, GitTag, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant