2

I am using below plugin for managing the patch version automatically.

id "com.zoltu.git-versioning" version "3.0.3"

Basically the above plugin requires code to be taged using v.major.minor convention. So, I have tagged the code with v0.1 and the tag is reachable form the HEAD.

But still I am getting below error -

  • What went wrong: A problem occurred evaluating root project 'report-service'.

Your repository must have at least one tag in it for git-versioning to work. Recommended solution: git tag v0.0

and git tag shows there is a tag and i have checked the revision history and this tag is reachable from the branch I am working on -

$ git tag
v0.1

Does anyone have any clue what the issue is. This a blocker for me.
Thanks in advance for any help..

1 Answers1

0

This actually comes from Zoltu/Gradle.Plugin.Versioning kotlin/com/zoltu/gradle/plugin/GitVersioning.kt

    private fun getGitDescribeResults(rootDirectory: File): String {
        val repository = FileRepositoryBuilder()
                .findGitDir(rootDirectory)!!
                .apply { gitDir ?: throw Exception("Project must be in a git directory for git-versioning to work.  Recommended solution: git init") }
                .build()!!
        val git = Git.wrap(repository)!!
        if (git.repository.allRefs.count() == 0) throw Exception("Your repository must have at least one commit in the repository for git-versioning to work.  Recommended solution: git commit")
        return git.describe().setLong(true).call() ?: throw Exception("Your repository must have at least one tag in it for git-versioning to work.  Recommended solution: git tag v0.0")
    }

As noted by torek in the comments, check if your tag is lightweight or annotated.
git describe would by default ignore lightweight tags.


In Zoltu/Gradle.Plugin.Versioning issue 25, Micah Zoltu (maintainer for that plugin) mentions having:

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hard to know without diving into the details of `git.describe()` in Kotlin here, but perhaps the tag must be an *annotated* tag as well? – torek Aug 30 '22 at 08:03
  • @torek Good point, thank you. I have edited the answer to make that possible cause more visible. – VonC Aug 30 '22 at 08:15
  • annotated tags helped +1 –  Aug 30 '22 at 09:52
  • @torek / VonC - would you mind taking a look at this too: https://stackoverflow.com/questions/73541172/com-gorylenko-generategitpropertiestask-property-gitproperties-is-missing-an any help is very much appreciated. –  Aug 30 '22 at 11:08